Skip to content

Commit

Permalink
Merge pull request #111 from phate999/master
Browse files Browse the repository at this point in the history
Added create() function
  • Loading branch information
phate999 authored Feb 21, 2024
2 parents 96b5206 + 624d591 commit cbfa909
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 30 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/**
Expand All @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions app_template/app_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# app_template - app framework using csclient.py
from csclient import EventingCSClient
cp = EventingCSClient('app_template')
cp.log('Starting...')
File renamed without changes.
12 changes: 12 additions & 0 deletions app_template/package.ini
Original file line number Diff line number Diff line change
@@ -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
13 changes: 4 additions & 9 deletions app_template_csclient/readme.txt → app_template/readme.txt
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
Application Name
================
app_template_csclient
app_template


Application Version
===================
1.0
0.1.0


NCOS Devices Supported
======================
Expand All @@ -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
2 changes: 2 additions & 0 deletions app_template/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
cppython app_template.py
4 changes: 0 additions & 4 deletions app_template_csclient/app_template_csclient.py

This file was deleted.

12 changes: 0 additions & 12 deletions app_template_csclient/package.ini

This file was deleted.

2 changes: 0 additions & 2 deletions app_template_csclient/start.sh

This file was deleted.

34 changes: 33 additions & 1 deletion make.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -312,6 +339,8 @@ def output_help():
print('Command format is: {} make.py <action>\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.')
Expand Down Expand Up @@ -449,6 +478,9 @@ def init(ceate_new_uuid):
else:
package()

elif utility_name == 'create':
create()

elif utility_name == 'status':
status()

Expand Down

0 comments on commit cbfa909

Please sign in to comment.