diff --git a/README.md b/README.md index 08924b92..97e5f278 100755 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ The Application Developers Guide is the best document to read first. ## Files - **make.py** - - The main python tool used to build application packages and install, uninstall, start, stop, or purge from a locally connected device that is in DEV mode. + - The main python tool used to manage application paackages. Supports actions: create, build, install, uninstall, start, stop, or purge from a locally connected device that is in DEV mode. - **sdk_settings.ini** - This is the ini file that contains the settings used by python make.py. - **tools/** @@ -26,7 +26,7 @@ The Application Developers Guide is the best document to read first. - **5GSpeed** - Run Ookla speedtests via NCM API. Results are put in asset_id field (configurable in SDK Data). Clearing the results starts a new test. This can be done easily via NCM API v2 /routers/ endpoint. -- **app_template_csclient** +- **app_template** - A template for the creation of a new application utilizing the csclient library. - **app_holder** - Just a holder for dynamic_app. See dynamic_app. diff --git a/app_template/app_template.py b/app_template/app_template.py new file mode 100644 index 00000000..8f7ee3a7 --- /dev/null +++ b/app_template/app_template.py @@ -0,0 +1,4 @@ +# app_template - app framework using csclient.py +from csclient import EventingCSClient +cp = EventingCSClient('app_template') +cp.log('Starting...') diff --git a/app_template_csclient/csclient.py b/app_template/csclient.py similarity index 100% rename from app_template_csclient/csclient.py rename to app_template/csclient.py diff --git a/app_template/package.ini b/app_template/package.ini new file mode 100644 index 00000000..d8282bba --- /dev/null +++ b/app_template/package.ini @@ -0,0 +1,12 @@ +[app_template] +uuid = +vendor = Cradlepoint +notes = App Template +version_major = 0 +version_minor = 1 +version_patch = 0 +auto_start = true +restart = true +reboot = true +firmware_major = 7 +firmware_minor = 24 diff --git a/app_template_csclient/readme.txt b/app_template/readme.txt old mode 100755 new mode 100644 similarity index 60% rename from app_template_csclient/readme.txt rename to app_template/readme.txt index 015efd9d..f8e433e5 --- a/app_template_csclient/readme.txt +++ b/app_template/readme.txt @@ -1,11 +1,12 @@ Application Name ================ -app_template_csclient +app_template Application Version =================== -1.0 +0.1.0 + NCOS Devices Supported ====================== @@ -19,10 +20,4 @@ None Application Purpose =================== -This is a template using SDK v3.0 csclient.py - - -Expected Output -=============== -Info Level Log Message: "Starting..." - +Application Template for creating new NCOS SDK applications \ No newline at end of file diff --git a/app_template/start.sh b/app_template/start.sh new file mode 100644 index 00000000..b8f63f9d --- /dev/null +++ b/app_template/start.sh @@ -0,0 +1,2 @@ +#!/bin/bash +cppython app_template.py \ No newline at end of file diff --git a/app_template_csclient/app_template_csclient.py b/app_template_csclient/app_template_csclient.py deleted file mode 100755 index d7a7b07a..00000000 --- a/app_template_csclient/app_template_csclient.py +++ /dev/null @@ -1,4 +0,0 @@ -# app_template_csclient - app framework using csclient.py -from csclient import EventingCSClient -cp = EventingCSClient('app_template_csclient') -cp.log('Starting...') diff --git a/app_template_csclient/package.ini b/app_template_csclient/package.ini deleted file mode 100755 index fd00b670..00000000 --- a/app_template_csclient/package.ini +++ /dev/null @@ -1,12 +0,0 @@ -[app_template_csclient] -uuid = -vendor = Cradlepoint -notes = Application Template -version_major = 1 -version_minor = 0 -version_patch = 0 -auto_start = true -restart = true -reboot = true -firmware_major = 7 -firmware_minor = 23 diff --git a/app_template_csclient/start.sh b/app_template_csclient/start.sh deleted file mode 100755 index 073bb0f2..00000000 --- a/app_template_csclient/start.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -cppython app_template_csclient.py \ No newline at end of file diff --git a/make.py b/make.py index ffe5851c..6036a814 100755 --- a/make.py +++ b/make.py @@ -232,8 +232,35 @@ def status(): response = get(status_tree) print(response) +# Create new app from app_template using supplied app name +def create(): + app_name = option + if not app_name: + print('Please include new app name. Example: python make.py create my_new_app') + return + if os.path.exists(app_name): + print('App already exists. Please choose a different name.') + return -# Transfer the app app tar.gz package to the NCOS device + try: + # Copy app_template folder and rename to new app name + shutil.copytree('app_template', app_name) + os.rename(f'{app_name}/app_template.py', f'{app_name}/{app_name}.py') + + # Replace app_template with new app name in all files + files = [f'{app_name}.py', 'package.ini', 'readme.txt', 'start.sh'] + for file in files: + path = f'{app_name}/{file}' + with open(path, 'r') as in_file: + filedata = in_file.read() + filedata = filedata.replace('app_template', app_name) + with open(path, 'w') as out_file: + out_file.write(filedata) + print(f'App {app_name} created successfully.') + except Exception as e: + print(f'Error creating app: {e}') + +# Transfer the app tar.gz package to the NCOS device def install(): if is_NCOS_device_in_DEV_mode(): app_archive = get_app_pack() @@ -312,6 +339,8 @@ def output_help(): print('Command format is: {} make.py \n'.format(g_python_cmd)) print('Actions include:') print('================') + print('create: Create a new app from the app_template folder.') + print(f'\tInclude new app name. Example: {g_python_cmd} make.py create my_new_app.\n') print('clean: Clean all project artifacts.') print('\tTo clean all the apps, add the option "all" (i.e. clean all).\n') print('build or package: Create the app archive tar.gz file.') @@ -449,6 +478,9 @@ def init(ceate_new_uuid): else: package() + elif utility_name == 'create': + create() + elif utility_name == 'status': status()