From dc61bf13d461f14ffd421f65a086b4c17ff2c1e3 Mon Sep 17 00:00:00 2001 From: Bryce Salmi Date: Sun, 30 Apr 2017 15:02:41 -0700 Subject: [PATCH 01/48] Added setup.py Initial add of setup.py for setuptools use when installing with pip. --- setup.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 setup.py diff --git a/setup.py b/setup.py new file mode 100644 index 00000000..4a199a90 --- /dev/null +++ b/setup.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python +#------------------------------------------------------------------------------- +# Name: /setup.py +# Purpose: Python setuptools setup.py file contains all information necessary +# to install faraday software with pip +# +# Author: Bryce Salmi +# +# Created: 4/30/2017 +# Licence: GPLv3 +#------------------------------------------------------------------------------- From ac7fbc2ebd3037e0d838838c279952b866901ca0 Mon Sep 17 00:00:00 2001 From: Bryce Salmi Date: Sun, 30 Apr 2017 15:21:06 -0700 Subject: [PATCH 02/48] Updated setup.py for Faraday Added Faraday specific data into the setup.py file. --- setup.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/setup.py b/setup.py index 4a199a90..319f0e89 100644 --- a/setup.py +++ b/setup.py @@ -9,3 +9,41 @@ # Created: 4/30/2017 # Licence: GPLv3 #------------------------------------------------------------------------------- + +import os +from setuptools import setup + +# serve README.txt from folder if queried for description +def read(fname): + return open(os.path.join(os.path.dirname(__file__), fname)).read() + +setup( + name = "faraday", + version = "0.0.1", + author = "FaradayRF", + author_email = "Support@FaradayRF.com", + description = "FaradayRF open source software for the Faraday radio.", + license = "GPLv3", + keywords = "faraday radio faradayrf ham amateur", + url = "https://www.FaradayRF.com", + packages=['faraday', 'tests'], + long_description=read('README'), + classifiers=[ + "Development Status :: 2 - Pre-Alpha", + "Framework :: Flask", + "Framework :: Pytest", + "Framework :: Flake8", + "Intended Audience :: Developers", + "Intended Audience :: Education", + "Intended Audience :: Science/Research", + "Natural Language :: English", + "Operating System :: MacOS :: MacOS X", + "Operating System :: Microsoft :: Windows", + "Operating System :: POSIX :: Linux", + "Programming Language :: Python", + "Programming Language :: JavaScript", + "Topic :: Scientific/Engineering", + "Topic :: Communications :: Ham Radio", + "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", + ], +) \ No newline at end of file From 991dfcf10b9f0d95d9dc3eec10a71230ba2298b6 Mon Sep 17 00:00:00 2001 From: Bryce Salmi Date: Sun, 30 Apr 2017 15:32:53 -0700 Subject: [PATCH 03/48] Updated setup.py to register with pypi Removed test folder indicated in setup.py as well as changed the README to REAMDE.md in the same file. --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 319f0e89..e66062b3 100644 --- a/setup.py +++ b/setup.py @@ -26,8 +26,8 @@ def read(fname): license = "GPLv3", keywords = "faraday radio faradayrf ham amateur", url = "https://www.FaradayRF.com", - packages=['faraday', 'tests'], - long_description=read('README'), + packages=['faraday'], + long_description=read('README.md'), classifiers=[ "Development Status :: 2 - Pre-Alpha", "Framework :: Flask", From 27c4649b10467d9dc6a0190b8357bffd18789423 Mon Sep 17 00:00:00 2001 From: Bryce Salmi Date: Sun, 30 Apr 2017 16:47:08 -0700 Subject: [PATCH 04/48] Initial pypi files that sucessfully upload Still having 'pip install faraday' issues but it uploades to pypi! --- setup.cfg | 2 +- setup.py | 13 ++++--------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/setup.cfg b/setup.cfg index 313a89cd..3f472354 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,3 +1,3 @@ [tool:pytest] addopts = --flake8 -flake8-ignore = E262 E265 E266 E402 E501 +flake8-ignore = E262 E265 E266 E402 E501 \ No newline at end of file diff --git a/setup.py b/setup.py index e66062b3..d0d82205 100644 --- a/setup.py +++ b/setup.py @@ -10,24 +10,19 @@ # Licence: GPLv3 #------------------------------------------------------------------------------- -import os from setuptools import setup -# serve README.txt from folder if queried for description -def read(fname): - return open(os.path.join(os.path.dirname(__file__), fname)).read() - setup( name = "faraday", - version = "0.0.1", + version = "0.0.1a4", author = "FaradayRF", author_email = "Support@FaradayRF.com", - description = "FaradayRF open source software for the Faraday radio.", + description = "FaradayRF amateur radio open source software", license = "GPLv3", keywords = "faraday radio faradayrf ham amateur", - url = "https://www.FaradayRF.com", + url = "https://github.com/FaradayRF/Faraday-Software", packages=['faraday'], - long_description=read('README.md'), + long_description="FaradayRF software", classifiers=[ "Development Status :: 2 - Pre-Alpha", "Framework :: Flask", From 6562a0fec9c6b8c203d17a696f10bac18870e80e Mon Sep 17 00:00:00 2001 From: Bryce Salmi Date: Tue, 2 May 2017 00:21:25 -0700 Subject: [PATCH 05/48] Added requirements files Specified requirements in setup.py --- setup.py | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index d0d82205..960bd6f4 100644 --- a/setup.py +++ b/setup.py @@ -10,20 +10,21 @@ # Licence: GPLv3 #------------------------------------------------------------------------------- -from setuptools import setup +import setuptools -setup( + +setuptools.setup( name = "faraday", - version = "0.0.1a4", + version = "0.0.1a7", author = "FaradayRF", author_email = "Support@FaradayRF.com", description = "FaradayRF amateur radio open source software", license = "GPLv3", keywords = "faraday radio faradayrf ham amateur", url = "https://github.com/FaradayRF/Faraday-Software", - packages=['faraday'], - long_description="FaradayRF software", - classifiers=[ + packages = ['faraday','proxy', 'Proxy'], + long_description = "FaradayRF software", + classifiers = [ "Development Status :: 2 - Pre-Alpha", "Framework :: Flask", "Framework :: Pytest", @@ -41,4 +42,26 @@ "Topic :: Communications :: Ham Radio", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", ], + install_requires = ['appdirs', + 'click', + 'configparser', + 'enum34', + 'flake8', + 'Flask', + 'Flask-Cors', + 'itsdangerous', + 'Jinja2', + 'MarkupSafe', + 'mccabe', + 'packaging', + 'py', + 'pycodestyle', + 'pyflakes', + 'pyparsing', + 'pyserial', + 'pytest', + 'pytest-flake8', + 'requests', + 'six', + 'Werkzeug'], ) \ No newline at end of file From e2ea05fd7950d59adc65d414dd23ce2309445f80 Mon Sep 17 00:00:00 2001 From: Bryce Salmi Date: Tue, 2 May 2017 21:11:54 -0700 Subject: [PATCH 06/48] Removed bad Proxy folder from packages list --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 960bd6f4..26c00030 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ license = "GPLv3", keywords = "faraday radio faradayrf ham amateur", url = "https://github.com/FaradayRF/Faraday-Software", - packages = ['faraday','proxy', 'Proxy'], + packages = ['faraday','proxy'], long_description = "FaradayRF software", classifiers = [ "Development Status :: 2 - Pre-Alpha", From c0d1def59ba38d510a5bfd1c7bd49e57c2b01031 Mon Sep 17 00:00:00 2001 From: Bryce Salmi Date: Tue, 2 May 2017 21:12:44 -0700 Subject: [PATCH 07/48] Moved setup.py to setup.old.py for pbr Will move over to pbr and this requires a simplified setup.py. --- setup.py => setup.old.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename setup.py => setup.old.py (100%) diff --git a/setup.py b/setup.old.py similarity index 100% rename from setup.py rename to setup.old.py From 989bd4a218be848374192e62e22add728ec24e32 Mon Sep 17 00:00:00 2001 From: Bryce Salmi Date: Tue, 2 May 2017 21:15:46 -0700 Subject: [PATCH 08/48] Minimal pbr setup.py --- setup.py | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 setup.py diff --git a/setup.py b/setup.py new file mode 100644 index 00000000..a3d7fb97 --- /dev/null +++ b/setup.py @@ -0,0 +1,8 @@ +#!/usr/bin/env python + +from setuptools import setup + +setup( + setup_requires=['pbr>=1.9', 'setuptools>=17.1'], + pbr=True, +) \ No newline at end of file From 5f5cb976e010e3c2994aa574b5bf640f1f5f411c Mon Sep 17 00:00:00 2001 From: Bryce Salmi Date: Tue, 2 May 2017 21:26:13 -0700 Subject: [PATCH 09/48] Initial Faraday pbr configuration --- setup.cfg | 46 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 3f472354..c63cf577 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,3 +1,47 @@ [tool:pytest] addopts = --flake8 -flake8-ignore = E262 E265 E266 E402 E501 \ No newline at end of file +flake8-ignore = E262 E265 E266 E402 E501 + +[metadata] +name = faraday +author = FaradayRF +author-email = Support@FaradayRF.com +summary = FaradayRF amateur radio open source software +description-file = README +home-page = https://github.com/FaradayRF/Faraday-Software +license = GPLv3 +classifier = + "Development Status :: 2 - Pre-Alpha" + "Framework :: Flask" + "Framework :: Pytest" + "Framework :: Flake8" + "Intended Audience :: Developers" + "Intended Audience :: Education" + "Intended Audience :: Science/Research" + "Natural Language :: English" + "Operating System :: MacOS :: MacOS X" + "Operating System :: Microsoft :: Windows" + "Operating System :: POSIX :: Linux" + "Programming Language :: Python" + "Programming Language :: JavaScript" + "Topic :: Scientific/Engineering" + "Topic :: Communications :: Ham Radio" + "License :: OSI Approved :: GNU General Public License v3 (GPLv3)" + +keywords = + faraday + radio + faradayrf + ham + amateur + +[files] +packages = + faraday +data_files = + Proxy/ = Proxy/* + +[entry_points] +console_scripts = + faraday = faraday:proxy + \ No newline at end of file From b087fc9e87f0700ddd173ee0d37ca0b82732b7ad Mon Sep 17 00:00:00 2001 From: Bryce Salmi Date: Tue, 2 May 2017 21:33:53 -0700 Subject: [PATCH 10/48] pbr Based setup.cfg so far so good Faraday-proxy appears to work. Now I need to fix the formatters ini filer error per @hdmike. --- setup.cfg | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/setup.cfg b/setup.cfg index c63cf577..0c4e17dd 100644 --- a/setup.cfg +++ b/setup.cfg @@ -43,5 +43,4 @@ data_files = [entry_points] console_scripts = - faraday = faraday:proxy - \ No newline at end of file + faraday-proxy = faraday.proxy:main From 5c960940431f7e0a67d618e6b02021365650b3a8 Mon Sep 17 00:00:00 2001 From: Bryce Salmi Date: Tue, 2 May 2017 21:36:34 -0700 Subject: [PATCH 11/48] Fixed logging.ini import error Used @hdkmike suggested import code and the issue was fixed. Now I need to do the same for proxy.ini. --- faraday/proxy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/faraday/proxy.py b/faraday/proxy.py index 81c9c4ed..8f5c7e68 100644 --- a/faraday/proxy.py +++ b/faraday/proxy.py @@ -26,7 +26,7 @@ from faraday.uart import layer_4_service # Start logging after importing modules -filename = os.path.abspath("loggingConfig.ini") +filename = os.path.join(os.path.dirname(__file__), '..', 'Proxy', 'loggingConfig.ini') logging.config.fileConfig(filename) logger = logging.getLogger('Proxy') From 1d116777ca9ac1c9fc18a234c482156d4bda409e Mon Sep 17 00:00:00 2001 From: Bryce Salmi Date: Tue, 2 May 2017 21:38:51 -0700 Subject: [PATCH 12/48] Proxy.ini now imports Successfully made it past the proxy.ini import. Now we need to get the sqlite schema file imported as it fails when running faraday-proxy. --- faraday/proxy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/faraday/proxy.py b/faraday/proxy.py index 8f5c7e68..1c45d8aa 100644 --- a/faraday/proxy.py +++ b/faraday/proxy.py @@ -32,7 +32,7 @@ # Load Proxy Configuration from proxy.ini file proxyConfig = ConfigParser.RawConfigParser() -filename = os.path.abspath("proxy.ini") +filename = os.path.join(os.path.dirname(__file__), '..', 'Proxy', 'proxy.ini') proxyConfig.read(filename) # Create and initialize dictionary queues From 872db0ebd7d2a01dd6c67ccef6e5e26d8592ed74 Mon Sep 17 00:00:00 2001 From: Bryce Salmi Date: Tue, 2 May 2017 21:45:54 -0700 Subject: [PATCH 13/48] WORKING FARADAY-PROXY AFTER PIP INSTALL! After installing with pip in editable mode I can use the command faraday-proxy to start up the proxy application correctly! I simply brute forced the relative file paths for the database and database schema files. --- faraday/proxy.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/faraday/proxy.py b/faraday/proxy.py index 1c45d8aa..4ca57723 100644 --- a/faraday/proxy.py +++ b/faraday/proxy.py @@ -431,7 +431,11 @@ def initDB(): # Obtain configuration file names try: dbFilename = proxyConfig.get("DATABASE", "FILENAME") + dbFilename = os.path.join(os.path.dirname(__file__), '..', 'Proxy', dbFilename) + dbSchema = proxyConfig.get("DATABASE", "SCHEMANAME") + dbSchema = os.path.join(os.path.dirname(__file__), '..', 'Proxy', dbSchema) + except ConfigParser.Error as e: logger.error("ConfigParse.Error: " + str(e)) From 7cb74e4aaa9a7b7bc29cd9c09fc07a757bae2f01 Mon Sep 17 00:00:00 2001 From: Bryce Salmi Date: Tue, 2 May 2017 23:03:52 -0700 Subject: [PATCH 14/48] Initial faraday-telemetry command line working Imported faraday/telemetry.py directly as well as fixed up paths to configuration files and databases. --- faraday/telemetry.py | 11 +++++++++-- setup.cfg | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/faraday/telemetry.py b/faraday/telemetry.py index c451af8c..ea62b4a4 100644 --- a/faraday/telemetry.py +++ b/faraday/telemetry.py @@ -27,7 +27,8 @@ # Start logging after importing modules try: - logging.config.fileConfig('loggingConfig.ini') + filename = os.path.join(os.path.dirname(__file__), '..', 'Applications', 'Telemetry', 'loggingConfig.ini') + logging.config.fileConfig(filename) logger = logging.getLogger('telemetry') except ConfigParser.Error as e: @@ -38,7 +39,8 @@ # Load Telemetry Configuration from telemetry.ini file telemetryConfig = ConfigParser.RawConfigParser() -telemetryFile = telemetryConfig.read('telemetry.ini') +filename = os.path.join(os.path.dirname(__file__), '..', 'Applications', 'Telemetry', 'telemetry.ini') +telemetryFile = telemetryConfig.read(filename) if len(telemetryFile) == 0: # File missing, indicate error and infinite loop @@ -441,7 +443,9 @@ def initDB(): # Obtain configuration file names try: dbFilename = telemetryConfig.get("DATABASE", "FILENAME") + dbFilename = os.path.join(os.path.dirname(__file__), '..', 'Applications', 'Telemetry', dbFilename) dbSchema = telemetryConfig.get("DATABASE", "SCHEMANAME") + dbSchema = os.path.join(os.path.dirname(__file__), '..', 'Applications', 'Telemetry', dbSchema) except ConfigParser.Error as e: logger.error("ConfigParse.Error: " + str(e)) @@ -540,6 +544,7 @@ def sqlInsert(data): # Read in name of telemetry database try: db = telemetryConfig.get("DATABASE", "FILENAME") + db = os.path.join(os.path.dirname(__file__), '..', 'Applications', 'Telemetry', db) except ConfigParser.Error as e: logger.error("ConfigParse.Error: " + str(e)) @@ -651,6 +656,7 @@ def queryDb(parameters): # Open configuration file try: dbFilename = telemetryConfig.get("DATABASE", "FILENAME") + dbFilename = os.path.join(os.path.dirname(__file__), '..', 'Applications', 'Telemetry', dbFilename) except ConfigParser.Error as e: logger.error("ConfigParse.Error: " + str(e)) @@ -755,6 +761,7 @@ def queryStationsDb(parameters): # Get telemetry database name from configuration file try: dbFilename = telemetryConfig.get("DATABASE", "FILENAME") + dbFilename = os.path.join(os.path.dirname(__file__), '..', 'Applications', 'Telemetry', dbFilename) except ConfigParser.Error as e: logger.error("ConfigParse.Error: " + str(e)) diff --git a/setup.cfg b/setup.cfg index 0c4e17dd..5adc72fe 100644 --- a/setup.cfg +++ b/setup.cfg @@ -40,7 +40,9 @@ packages = faraday data_files = Proxy/ = Proxy/* + Applications/Telemetry/ = Applications/Telemetry/* [entry_points] console_scripts = faraday-proxy = faraday.proxy:main + faraday-telemetry = faraday.telemetry:main From 89ba681de9f1d0b0e2de820dda23cbedc83bddac Mon Sep 17 00:00:00 2001 From: Bryce Salmi Date: Tue, 2 May 2017 23:22:04 -0700 Subject: [PATCH 15/48] faraday-aprs working! Modified paths to configuration files in faraday/aprs.py as well as added correct lines to setup.cfg to properly create console entry points for faraday-aprs. --- faraday/aprs.py | 7 +++++-- setup.cfg | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/faraday/aprs.py b/faraday/aprs.py index 96dfddfe..c35d6dca 100644 --- a/faraday/aprs.py +++ b/faraday/aprs.py @@ -14,16 +14,19 @@ import ConfigParser import socket import requests +import os from time import sleep # Start logging after importing modules -logging.config.fileConfig('loggingConfig.ini') +filename = os.path.join(os.path.dirname(__file__), '..', 'Applications', 'APRS', 'loggingConfig.ini') +logging.config.fileConfig(filename) logger = logging.getLogger('APRS') # Load Telemetry Configuration from telemetry.ini file # Should have common file for apps... +filename = os.path.join(os.path.dirname(__file__), '..', 'Applications', 'APRS', 'aprs.ini') aprsConfig = ConfigParser.RawConfigParser() -aprsConfig.read('aprs.ini') +aprsConfig.read(filename) # Create and initialize dictionary queues telemetryDicts = {} diff --git a/setup.cfg b/setup.cfg index 5adc72fe..870a02a2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -41,8 +41,10 @@ packages = data_files = Proxy/ = Proxy/* Applications/Telemetry/ = Applications/Telemetry/* + Applications/APRS/ = Applications/APRS/* [entry_points] console_scripts = faraday-proxy = faraday.proxy:main faraday-telemetry = faraday.telemetry:main + faraday-aprs = faraday.aprs:main From 48ca3e0880e7370ff5ba033bce72b0764dce196b Mon Sep 17 00:00:00 2001 From: Bryce Salmi Date: Tue, 2 May 2017 23:31:56 -0700 Subject: [PATCH 16/48] faraday-simpleui now works! Very simple update of logging file locations as well as setup.cfg to point to the correct entry points. --- faraday/simpleui.py | 5 +++-- setup.cfg | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/faraday/simpleui.py b/faraday/simpleui.py index d37195c7..9fde0b41 100644 --- a/faraday/simpleui.py +++ b/faraday/simpleui.py @@ -27,13 +27,14 @@ from faraday.proxyio import gpioallocations # Start logging after importing modules -filename = os.path.abspath("loggingConfig.ini") +filename = os.path.join(os.path.dirname(__file__), '..', 'Applications', 'SimpleUI', 'loggingConfig.ini') +filename = os.path.abspath(filename) logging.config.fileConfig(filename) logger = logging.getLogger('SimpleUI') # Load configuration file simpleuiconfig = ConfigParser.RawConfigParser() -filename = os.path.abspath("simpleui.ini") +filename = os.path.join(os.path.dirname(__file__), '..', 'Applications', 'SimpleUI', 'simpleui.ini') simpleuiconfig.read(filename) # Initialize Flask microframework diff --git a/setup.cfg b/setup.cfg index 870a02a2..1a967727 100644 --- a/setup.cfg +++ b/setup.cfg @@ -42,9 +42,11 @@ data_files = Proxy/ = Proxy/* Applications/Telemetry/ = Applications/Telemetry/* Applications/APRS/ = Applications/APRS/* + Applications/SimpleUI/ = Applications/SimpleUI/* [entry_points] console_scripts = faraday-proxy = faraday.proxy:main faraday-telemetry = faraday.telemetry:main faraday-aprs = faraday.aprs:main + faraday-simpleui = faraday.simpleui:main From f0196f1b7edae45a3aeebafe68a07b4c2f71c750 Mon Sep 17 00:00:00 2001 From: Bryce Salmi Date: Wed, 3 May 2017 00:24:37 -0700 Subject: [PATCH 17/48] Updated setup.cfg for correct file import in pbr --- setup.cfg | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/setup.cfg b/setup.cfg index 1a967727..53049425 100644 --- a/setup.cfg +++ b/setup.cfg @@ -39,10 +39,19 @@ keywords = packages = faraday data_files = - Proxy/ = Proxy/* - Applications/Telemetry/ = Applications/Telemetry/* - Applications/APRS/ = Applications/APRS/* - Applications/SimpleUI/ = Applications/SimpleUI/* + Proxy/examplelogs/ = Proxy/examplelogs/* + Proxy = Proxy/db.sql + Proxy/loggingConfig.ini + Proxy/proxy.sample.ini + Applications/Telemetry = Applications/Telemetry/db.sql + Applications/Telemetry/loggingConfig.ini + Applications/Telemetry/telemetry.sample.ini + Applications/SimpleUI/static = Applications/SimpleUI/static/* + Applications/SimpleUI/templates = Applications/SimpleUI/templates/* + Applications/SimpleUI = Applications/SimpleUI/loggingConfig.ini + Applications/SimpleUI/simpleui.sample.ini + Applications/APRS = Applications/APRS/aprs.sample.ini + Applications/APRS/loggingConfig.ini [entry_points] console_scripts = From 3cfb0ebe1aa6f9410523fe9306ecea3889ea3661 Mon Sep 17 00:00:00 2001 From: Bryce Salmi Date: Wed, 3 May 2017 00:26:35 -0700 Subject: [PATCH 18/48] Added README --- README | 1 + 1 file changed, 1 insertion(+) create mode 100644 README diff --git a/README b/README new file mode 100644 index 00000000..1c9b3054 --- /dev/null +++ b/README @@ -0,0 +1 @@ +faradayrf \ No newline at end of file From 74285344ef9cc2dd5f6e5fcb9dc1e04c681e3e28 Mon Sep 17 00:00:00 2001 From: Bryce Salmi Date: Thu, 4 May 2017 00:29:08 -0700 Subject: [PATCH 19/48] Updated setup.cfg to fix data_file Fixed data_file formatting and also forced a difference base version so I can upload to pypi without committing. --- setup.cfg | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/setup.cfg b/setup.cfg index 53049425..a034ef34 100644 --- a/setup.cfg +++ b/setup.cfg @@ -10,6 +10,7 @@ summary = FaradayRF amateur radio open source software description-file = README home-page = https://github.com/FaradayRF/Faraday-Software license = GPLv3 +version = 0.0.1001 classifier = "Development Status :: 2 - Pre-Alpha" "Framework :: Flask" @@ -40,18 +41,22 @@ packages = faraday data_files = Proxy/examplelogs/ = Proxy/examplelogs/* - Proxy = Proxy/db.sql - Proxy/loggingConfig.ini - Proxy/proxy.sample.ini - Applications/Telemetry = Applications/Telemetry/db.sql - Applications/Telemetry/loggingConfig.ini - Applications/Telemetry/telemetry.sample.ini + Proxy = + Proxy/db.sql + Proxy/loggingConfig.ini + Proxy/proxy.sample.ini + Applications/Telemetry = + Applications/Telemetry/db.sql + Applications/Telemetry/loggingConfig.ini + Applications/Telemetry/telemetry.sample.ini Applications/SimpleUI/static = Applications/SimpleUI/static/* Applications/SimpleUI/templates = Applications/SimpleUI/templates/* - Applications/SimpleUI = Applications/SimpleUI/loggingConfig.ini - Applications/SimpleUI/simpleui.sample.ini - Applications/APRS = Applications/APRS/aprs.sample.ini - Applications/APRS/loggingConfig.ini + Applications/SimpleUI = + Applications/SimpleUI/loggingConfig.ini + Applications/SimpleUI/simpleui.sample.ini + Applications/APRS = + Applications/APRS/aprs.sample.ini + Applications/APRS/loggingConfig.ini [entry_points] console_scripts = From 404b02f51e1803361a6d916cebc46a1d9c70bb0b Mon Sep 17 00:00:00 2001 From: Bryce Salmi Date: Thu, 4 May 2017 01:18:55 -0700 Subject: [PATCH 20/48] Added updates for config file relative paths. --- faraday/proxy.py | 9 +++++---- setup.cfg | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/faraday/proxy.py b/faraday/proxy.py index 4ca57723..50749b93 100644 --- a/faraday/proxy.py +++ b/faraday/proxy.py @@ -26,13 +26,14 @@ from faraday.uart import layer_4_service # Start logging after importing modules -filename = os.path.join(os.path.dirname(__file__), '..', 'Proxy', 'loggingConfig.ini') +filename = os.path.join(os.path.dirname(__file__), '../../../', 'Proxy', 'loggingConfig.ini') +logging.error(filename) logging.config.fileConfig(filename) logger = logging.getLogger('Proxy') # Load Proxy Configuration from proxy.ini file proxyConfig = ConfigParser.RawConfigParser() -filename = os.path.join(os.path.dirname(__file__), '..', 'Proxy', 'proxy.ini') +filename = os.path.join(os.path.dirname(__file__), '../../../', 'Proxy', 'proxy.ini') proxyConfig.read(filename) # Create and initialize dictionary queues @@ -431,10 +432,10 @@ def initDB(): # Obtain configuration file names try: dbFilename = proxyConfig.get("DATABASE", "FILENAME") - dbFilename = os.path.join(os.path.dirname(__file__), '..', 'Proxy', dbFilename) + dbFilename = os.path.join(os.path.dirname(__file__), '../../../', 'Proxy', dbFilename) dbSchema = proxyConfig.get("DATABASE", "SCHEMANAME") - dbSchema = os.path.join(os.path.dirname(__file__), '..', 'Proxy', dbSchema) + dbSchema = os.path.join(os.path.dirname(__file__), '../../../', 'Proxy', dbSchema) except ConfigParser.Error as e: diff --git a/setup.cfg b/setup.cfg index a034ef34..614f173a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -10,7 +10,7 @@ summary = FaradayRF amateur radio open source software description-file = README home-page = https://github.com/FaradayRF/Faraday-Software license = GPLv3 -version = 0.0.1001 +version = 0.0.1004 classifier = "Development Status :: 2 - Pre-Alpha" "Framework :: Flask" From 48323aa6112a4ff52faddad7a87cc13f5f3f4942 Mon Sep 17 00:00:00 2001 From: Bryce Salmi Date: Sat, 6 May 2017 12:55:16 -0700 Subject: [PATCH 21/48] Moved proxy.sample.ini to main project folder --- Proxy/proxy.sample.ini => proxy.sample.ini | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Proxy/proxy.sample.ini => proxy.sample.ini (100%) diff --git a/Proxy/proxy.sample.ini b/proxy.sample.ini similarity index 100% rename from Proxy/proxy.sample.ini rename to proxy.sample.ini From c25bcb45e8086cbc11fa48b338b9c416058430ee Mon Sep 17 00:00:00 2001 From: Bryce Salmi Date: Sat, 6 May 2017 13:09:10 -0700 Subject: [PATCH 22/48] Moved proxy.sample.ini into a new etc/ folder --- proxy.sample.ini => etc/proxy.sample.ini | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename proxy.sample.ini => etc/proxy.sample.ini (100%) diff --git a/proxy.sample.ini b/etc/proxy.sample.ini similarity index 100% rename from proxy.sample.ini rename to etc/proxy.sample.ini From 9f2dba21497b69f69cfceb619ead027327b03c52 Mon Sep 17 00:00:00 2001 From: Bryce Salmi Date: Sat, 6 May 2017 13:44:41 -0700 Subject: [PATCH 23/48] Moved proxy files to etc Updated proxy.py to use configuration files from etc/ folder. --- {Proxy => etc}/db.sql | 0 {Proxy => etc}/loggingConfig.ini | 0 faraday/proxy.py | 9 ++++----- setup.cfg | 19 ++----------------- 4 files changed, 6 insertions(+), 22 deletions(-) rename {Proxy => etc}/db.sql (100%) rename {Proxy => etc}/loggingConfig.ini (100%) diff --git a/Proxy/db.sql b/etc/db.sql similarity index 100% rename from Proxy/db.sql rename to etc/db.sql diff --git a/Proxy/loggingConfig.ini b/etc/loggingConfig.ini similarity index 100% rename from Proxy/loggingConfig.ini rename to etc/loggingConfig.ini diff --git a/faraday/proxy.py b/faraday/proxy.py index 50749b93..65116028 100644 --- a/faraday/proxy.py +++ b/faraday/proxy.py @@ -26,14 +26,13 @@ from faraday.uart import layer_4_service # Start logging after importing modules -filename = os.path.join(os.path.dirname(__file__), '../../../', 'Proxy', 'loggingConfig.ini') -logging.error(filename) +filename = os.path.join('etc', 'loggingConfig.ini') logging.config.fileConfig(filename) logger = logging.getLogger('Proxy') # Load Proxy Configuration from proxy.ini file proxyConfig = ConfigParser.RawConfigParser() -filename = os.path.join(os.path.dirname(__file__), '../../../', 'Proxy', 'proxy.ini') +filename = os.path.join('etc', 'proxy.ini') proxyConfig.read(filename) # Create and initialize dictionary queues @@ -432,10 +431,10 @@ def initDB(): # Obtain configuration file names try: dbFilename = proxyConfig.get("DATABASE", "FILENAME") - dbFilename = os.path.join(os.path.dirname(__file__), '../../../', 'Proxy', dbFilename) + dbFilename = os.path.join('etc', dbFilename) dbSchema = proxyConfig.get("DATABASE", "SCHEMANAME") - dbSchema = os.path.join(os.path.dirname(__file__), '../../../', 'Proxy', dbSchema) + dbSchema = os.path.join('etc', dbSchema) except ConfigParser.Error as e: diff --git a/setup.cfg b/setup.cfg index 614f173a..e59f33a4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -40,23 +40,8 @@ keywords = packages = faraday data_files = - Proxy/examplelogs/ = Proxy/examplelogs/* - Proxy = - Proxy/db.sql - Proxy/loggingConfig.ini - Proxy/proxy.sample.ini - Applications/Telemetry = - Applications/Telemetry/db.sql - Applications/Telemetry/loggingConfig.ini - Applications/Telemetry/telemetry.sample.ini - Applications/SimpleUI/static = Applications/SimpleUI/static/* - Applications/SimpleUI/templates = Applications/SimpleUI/templates/* - Applications/SimpleUI = - Applications/SimpleUI/loggingConfig.ini - Applications/SimpleUI/simpleui.sample.ini - Applications/APRS = - Applications/APRS/aprs.sample.ini - Applications/APRS/loggingConfig.ini + + etc/ = etc/* [entry_points] console_scripts = From 2b8f194d08de7cac21f6623f32522775e52ae375 Mon Sep 17 00:00:00 2001 From: Bryce Salmi Date: Sat, 6 May 2017 15:00:37 -0700 Subject: [PATCH 24/48] Added test.txt to create etc/faraday folder --- etc/faraday/test.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 etc/faraday/test.txt diff --git a/etc/faraday/test.txt b/etc/faraday/test.txt new file mode 100644 index 00000000..e69de29b From 3d35f34ee5206a56995da261228662218568b6d8 Mon Sep 17 00:00:00 2001 From: Bryce Salmi Date: Sat, 6 May 2017 15:11:16 -0700 Subject: [PATCH 25/48] Moved /etc files into /etc/faraday To ensure all files are in a common faraday folder. --- etc/{ => faraday}/db.sql | 0 etc/{ => faraday}/loggingConfig.ini | 0 etc/{ => faraday}/proxy.sample.ini | 0 etc/faraday/test.txt | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename etc/{ => faraday}/db.sql (100%) rename etc/{ => faraday}/loggingConfig.ini (100%) rename etc/{ => faraday}/proxy.sample.ini (100%) delete mode 100644 etc/faraday/test.txt diff --git a/etc/db.sql b/etc/faraday/db.sql similarity index 100% rename from etc/db.sql rename to etc/faraday/db.sql diff --git a/etc/loggingConfig.ini b/etc/faraday/loggingConfig.ini similarity index 100% rename from etc/loggingConfig.ini rename to etc/faraday/loggingConfig.ini diff --git a/etc/proxy.sample.ini b/etc/faraday/proxy.sample.ini similarity index 100% rename from etc/proxy.sample.ini rename to etc/faraday/proxy.sample.ini diff --git a/etc/faraday/test.txt b/etc/faraday/test.txt deleted file mode 100644 index e69de29b..00000000 From e230a4fb1ca41e04e1b735ece1c6a58524289efc Mon Sep 17 00:00:00 2001 From: Bryce Salmi Date: Sat, 6 May 2017 15:22:00 -0700 Subject: [PATCH 26/48] Added updated proxy.py for /etc/faraday files updated file paths to enable use of /etc/faraday/ --- faraday/proxy.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/faraday/proxy.py b/faraday/proxy.py index 65116028..9d3c7ad3 100644 --- a/faraday/proxy.py +++ b/faraday/proxy.py @@ -26,13 +26,13 @@ from faraday.uart import layer_4_service # Start logging after importing modules -filename = os.path.join('etc', 'loggingConfig.ini') +filename = os.path.join('etc', 'faraday', 'loggingConfig.ini') logging.config.fileConfig(filename) logger = logging.getLogger('Proxy') # Load Proxy Configuration from proxy.ini file proxyConfig = ConfigParser.RawConfigParser() -filename = os.path.join('etc', 'proxy.ini') +filename = os.path.join('etc', 'faraday', 'proxy.ini') proxyConfig.read(filename) # Create and initialize dictionary queues @@ -431,10 +431,10 @@ def initDB(): # Obtain configuration file names try: dbFilename = proxyConfig.get("DATABASE", "FILENAME") - dbFilename = os.path.join('etc', dbFilename) + dbFilename = os.path.join('etc', 'faraday', dbFilename) dbSchema = proxyConfig.get("DATABASE", "SCHEMANAME") - dbSchema = os.path.join('etc', dbSchema) + dbSchema = os.path.join('etc', 'faraday', dbSchema) except ConfigParser.Error as e: From 1584ceea66265c27fe39a7aab72847b96277beaa Mon Sep 17 00:00:00 2001 From: Bryce Salmi Date: Wed, 10 May 2017 23:07:42 -0700 Subject: [PATCH 27/48] Updated for dynamic config files After talking to @hdkmike and @reillyeon we figured out a path forward for python packaging and config file locations. This is a sort of brute force attempt to get this working so not pretty but I don't want to optimise until I know we actually understand this. --- faraday/proxy.py | 29 ++++++++++++++++++++--------- setup.cfg | 8 +++++--- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/faraday/proxy.py b/faraday/proxy.py index 9d3c7ad3..14ab5886 100644 --- a/faraday/proxy.py +++ b/faraday/proxy.py @@ -26,14 +26,24 @@ from faraday.uart import layer_4_service # Start logging after importing modules -filename = os.path.join('etc', 'faraday', 'loggingConfig.ini') -logging.config.fileConfig(filename) + +relpath = os.path.join('..', 'etc', 'faraday') +setuppath = os.path.join(sys.prefix, 'etc', 'faraday') +userpath = os.path.expanduser('~/.faraday') +path = '' + +for location in os.curdir, relpath, setuppath, userpath: + try: + logging.config.fileConfig(os.path.join(location, "loggingConfig.ini")) + path = location + break + except ConfigParser.NoSectionError: + pass logger = logging.getLogger('Proxy') # Load Proxy Configuration from proxy.ini file proxyConfig = ConfigParser.RawConfigParser() -filename = os.path.join('etc', 'faraday', 'proxy.ini') -proxyConfig.read(filename) +proxyConfig.read(os.path.join(path, "proxy.ini")) # Create and initialize dictionary queues postDict = {} @@ -431,11 +441,11 @@ def initDB(): # Obtain configuration file names try: dbFilename = proxyConfig.get("DATABASE", "FILENAME") - dbFilename = os.path.join('etc', 'faraday', dbFilename) + dbFilename = os.path.join(path, dbFilename) - dbSchema = proxyConfig.get("DATABASE", "SCHEMANAME") - dbSchema = os.path.join('etc', 'faraday', dbSchema) + dbSchema = proxyConfig.get("DATABASE", "SCHEMANAME") + dbSchema = os.path.join(path, dbSchema) except ConfigParser.Error as e: logger.error("ConfigParse.Error: " + str(e)) @@ -527,7 +537,8 @@ def sqlInsert(data): # Read in name of database try: - db = proxyConfig.get("DATABASE", "FILENAME") + dbFilename = proxyConfig.get("DATABASE", "FILENAME") + dbFilename = os.path.join(path, dbFilename) except ConfigParser.Error as e: logger.error("ConfigParse.Error: " + str(e)) @@ -545,7 +556,7 @@ def sqlInsert(data): # Connect to database, create SQL query, execute query, and close database try: - conn = sqlite3.connect(db) + conn = sqlite3.connect(dbFilename) except sqlite3.Error as e: logger.error("Sqlite3.Error: " + str(e)) diff --git a/setup.cfg b/setup.cfg index e59f33a4..c222ea53 100644 --- a/setup.cfg +++ b/setup.cfg @@ -40,9 +40,11 @@ keywords = packages = faraday data_files = - - etc/ = etc/* - + etc/faraday = + Proxy/proxy.ini + Proxy/loggingConfig.ini + Applications/Telemetry.ini + [entry_points] console_scripts = faraday-proxy = faraday.proxy:main From b975466fb7a0e859c877bca73e90c4867b36b19c Mon Sep 17 00:00:00 2001 From: Bryce Salmi Date: Wed, 10 May 2017 23:32:28 -0700 Subject: [PATCH 28/48] A working installable version of proxy Had to change some files around but this version works! Added a new path element as well. Still very brute forced. The user MUST copy proxy.sample.ini over to proxy.ini and edit it all manually right now. Also, the log file is created in /etc and it shouldn't but one step at a time. --- faraday/proxy.py | 7 +++++-- setup.cfg | 6 +++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/faraday/proxy.py b/faraday/proxy.py index 14ab5886..71b21c73 100644 --- a/faraday/proxy.py +++ b/faraday/proxy.py @@ -27,18 +27,21 @@ # Start logging after importing modules -relpath = os.path.join('..', 'etc', 'faraday') +relpath1 = os.path.join('etc', 'faraday') +relpath2 = os.path.join('..', 'etc', 'faraday') setuppath = os.path.join(sys.prefix, 'etc', 'faraday') userpath = os.path.expanduser('~/.faraday') path = '' -for location in os.curdir, relpath, setuppath, userpath: +for location in os.curdir, relpath1, relpath2, setuppath, userpath: try: + print location logging.config.fileConfig(os.path.join(location, "loggingConfig.ini")) path = location break except ConfigParser.NoSectionError: pass + logger = logging.getLogger('Proxy') # Load Proxy Configuration from proxy.ini file diff --git a/setup.cfg b/setup.cfg index c222ea53..c141ec3a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -41,9 +41,9 @@ packages = faraday data_files = etc/faraday = - Proxy/proxy.ini - Proxy/loggingConfig.ini - Applications/Telemetry.ini + etc/faraday/proxy.sample.ini + etc/faraday/loggingConfig.ini + etc/faraday/db.sql [entry_points] console_scripts = From 2e7955b64de86315d09c8c8dc4953b898c26c7ac Mon Sep 17 00:00:00 2001 From: Bryce Salmi Date: Wed, 10 May 2017 23:54:24 -0700 Subject: [PATCH 29/48] Working testmode and create folder tree for lib Decided to save the log files in ~/faraday/.faraday/lib which now works. Not sure if long term want to keep this current structure with lib in user area and etc in python sys.prefix. Again, brute force trying to understand the workings of it all. Progress! --- faraday/proxy.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/faraday/proxy.py b/faraday/proxy.py index 71b21c73..5b2ef9a6 100644 --- a/faraday/proxy.py +++ b/faraday/proxy.py @@ -440,12 +440,16 @@ def initDB(): :return: True or False if successful """ + # make directory tree, necessary? + try: + os.makedirs(os.path.join(os.path.expanduser('~'), '.faraday.', 'lib')) + except: + pass - # Obtain configuration file names + # Obtain configuration file names, always place at sys.prefix try: dbFilename = proxyConfig.get("DATABASE", "FILENAME") - dbFilename = os.path.join(path, dbFilename) - + dbFilename = os.path.join(os.path.expanduser('~'),'.faraday.', 'lib', dbFilename) dbSchema = proxyConfig.get("DATABASE", "SCHEMANAME") dbSchema = os.path.join(path, dbSchema) @@ -485,6 +489,7 @@ def openTestDB(): # Obtain configuration file names try: testDbFilename = proxyConfig.get("TESTDATABASE", "FILENAME") + testDbFilename = os.path.join(os.path.expanduser('~'), '.faraday.', 'lib', testDbFilename) except ConfigParser.Error as e: logger.error("ConfigParse.Error: " + str(e)) @@ -541,7 +546,8 @@ def sqlInsert(data): # Read in name of database try: dbFilename = proxyConfig.get("DATABASE", "FILENAME") - dbFilename = os.path.join(path, dbFilename) + print os.path.join(os.path.expanduser('~'),'.faraday.', 'lib', dbFilename) + dbFilename = os.path.join(os.path.expanduser('~'),'.faraday.', 'lib', dbFilename) except ConfigParser.Error as e: logger.error("ConfigParse.Error: " + str(e)) From 326ee12bbe402a847fdad5870802d3f594b6cb80 Mon Sep 17 00:00:00 2001 From: Bryce Salmi Date: Thu, 11 May 2017 00:07:24 -0700 Subject: [PATCH 30/48] Fixed PEP8 Errors Per pytest Ran pytest and fixed the PEP8 errors/warnings. --- faraday/proxy.py | 6 ++--- setup.old.py | 67 ------------------------------------------------ setup.py | 2 +- 3 files changed, 4 insertions(+), 71 deletions(-) delete mode 100644 setup.old.py diff --git a/faraday/proxy.py b/faraday/proxy.py index 5b2ef9a6..18f19383 100644 --- a/faraday/proxy.py +++ b/faraday/proxy.py @@ -449,7 +449,7 @@ def initDB(): # Obtain configuration file names, always place at sys.prefix try: dbFilename = proxyConfig.get("DATABASE", "FILENAME") - dbFilename = os.path.join(os.path.expanduser('~'),'.faraday.', 'lib', dbFilename) + dbFilename = os.path.join(os.path.expanduser('~'), '.faraday.', 'lib', dbFilename) dbSchema = proxyConfig.get("DATABASE", "SCHEMANAME") dbSchema = os.path.join(path, dbSchema) @@ -546,8 +546,8 @@ def sqlInsert(data): # Read in name of database try: dbFilename = proxyConfig.get("DATABASE", "FILENAME") - print os.path.join(os.path.expanduser('~'),'.faraday.', 'lib', dbFilename) - dbFilename = os.path.join(os.path.expanduser('~'),'.faraday.', 'lib', dbFilename) + print os.path.join(os.path.expanduser('~'), '.faraday.', 'lib', dbFilename) + dbFilename = os.path.join(os.path.expanduser('~'), '.faraday.', 'lib', dbFilename) except ConfigParser.Error as e: logger.error("ConfigParse.Error: " + str(e)) diff --git a/setup.old.py b/setup.old.py deleted file mode 100644 index 26c00030..00000000 --- a/setup.old.py +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env python -#------------------------------------------------------------------------------- -# Name: /setup.py -# Purpose: Python setuptools setup.py file contains all information necessary -# to install faraday software with pip -# -# Author: Bryce Salmi -# -# Created: 4/30/2017 -# Licence: GPLv3 -#------------------------------------------------------------------------------- - -import setuptools - - -setuptools.setup( - name = "faraday", - version = "0.0.1a7", - author = "FaradayRF", - author_email = "Support@FaradayRF.com", - description = "FaradayRF amateur radio open source software", - license = "GPLv3", - keywords = "faraday radio faradayrf ham amateur", - url = "https://github.com/FaradayRF/Faraday-Software", - packages = ['faraday','proxy'], - long_description = "FaradayRF software", - classifiers = [ - "Development Status :: 2 - Pre-Alpha", - "Framework :: Flask", - "Framework :: Pytest", - "Framework :: Flake8", - "Intended Audience :: Developers", - "Intended Audience :: Education", - "Intended Audience :: Science/Research", - "Natural Language :: English", - "Operating System :: MacOS :: MacOS X", - "Operating System :: Microsoft :: Windows", - "Operating System :: POSIX :: Linux", - "Programming Language :: Python", - "Programming Language :: JavaScript", - "Topic :: Scientific/Engineering", - "Topic :: Communications :: Ham Radio", - "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", - ], - install_requires = ['appdirs', - 'click', - 'configparser', - 'enum34', - 'flake8', - 'Flask', - 'Flask-Cors', - 'itsdangerous', - 'Jinja2', - 'MarkupSafe', - 'mccabe', - 'packaging', - 'py', - 'pycodestyle', - 'pyflakes', - 'pyparsing', - 'pyserial', - 'pytest', - 'pytest-flake8', - 'requests', - 'six', - 'Werkzeug'], -) \ No newline at end of file diff --git a/setup.py b/setup.py index a3d7fb97..ce14d42e 100644 --- a/setup.py +++ b/setup.py @@ -5,4 +5,4 @@ setup( setup_requires=['pbr>=1.9', 'setuptools>=17.1'], pbr=True, -) \ No newline at end of file +) From f470735229f3dc12e51467c560c6618691569054 Mon Sep 17 00:00:00 2001 From: kb1lqc Date: Sun, 28 May 2017 09:54:26 -0700 Subject: [PATCH 31/48] Updated configuration imports Updated the print statements to use logging debug statements and also cleaned up some path naming. --- faraday/proxy.py | 15 ++++++++++----- setup.cfg | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/faraday/proxy.py b/faraday/proxy.py index 18f19383..c5fc6f04 100644 --- a/faraday/proxy.py +++ b/faraday/proxy.py @@ -35,7 +35,6 @@ for location in os.curdir, relpath1, relpath2, setuppath, userpath: try: - print location logging.config.fileConfig(os.path.join(location, "loggingConfig.ini")) path = location break @@ -43,6 +42,7 @@ pass logger = logging.getLogger('Proxy') +logger.debug("PATH: " + path) # Load Proxy Configuration from proxy.ini file proxyConfig = ConfigParser.RawConfigParser() @@ -449,7 +449,9 @@ def initDB(): # Obtain configuration file names, always place at sys.prefix try: dbFilename = proxyConfig.get("DATABASE", "FILENAME") - dbFilename = os.path.join(os.path.expanduser('~'), '.faraday.', 'lib', dbFilename) + dbPath = os.path.join(os.path.expanduser('~'), '.faraday.', 'lib', dbFilename) + logger.debug("Proxy Database: " + dbPath) + dbFilename = dbPath dbSchema = proxyConfig.get("DATABASE", "SCHEMANAME") dbSchema = os.path.join(path, dbSchema) @@ -489,7 +491,9 @@ def openTestDB(): # Obtain configuration file names try: testDbFilename = proxyConfig.get("TESTDATABASE", "FILENAME") - testDbFilename = os.path.join(os.path.expanduser('~'), '.faraday.', 'lib', testDbFilename) + dbPath = os.path.join(os.path.expanduser('~'), '.faraday.', 'lib', testDbFilename) + logger.debug("Proxy Test Database: " + dbPath) + testDbFilename = dbPath except ConfigParser.Error as e: logger.error("ConfigParse.Error: " + str(e)) @@ -546,8 +550,9 @@ def sqlInsert(data): # Read in name of database try: dbFilename = proxyConfig.get("DATABASE", "FILENAME") - print os.path.join(os.path.expanduser('~'), '.faraday.', 'lib', dbFilename) - dbFilename = os.path.join(os.path.expanduser('~'), '.faraday.', 'lib', dbFilename) + dbPath = os.path.join(os.path.expanduser('~'), '.faraday.', 'lib', dbFilename) + logger.debug("Proxy Database: " + dbPath) + dbFilename = os.path.join(dbPath) except ConfigParser.Error as e: logger.error("ConfigParse.Error: " + str(e)) diff --git a/setup.cfg b/setup.cfg index c141ec3a..02f969f7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -10,7 +10,7 @@ summary = FaradayRF amateur radio open source software description-file = README home-page = https://github.com/FaradayRF/Faraday-Software license = GPLv3 -version = 0.0.1004 +version = 0.0.1008 classifier = "Development Status :: 2 - Pre-Alpha" "Framework :: Flask" From 50192b88d77eb3d64324d8da1b75faeef7b36527 Mon Sep 17 00:00:00 2001 From: kb1lqc Date: Sun, 28 May 2017 11:55:21 -0700 Subject: [PATCH 32/48] Successfully configured proxy from command line Very basic and still hacky I can now command line initialize the proxy.ini file and then save basic configurations to it. --- faraday/proxy.py | 40 +++++++++++++++++++++++++++++++++++++++- requirements.txt | 1 + 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/faraday/proxy.py b/faraday/proxy.py index c5fc6f04..49a12979 100644 --- a/faraday/proxy.py +++ b/faraday/proxy.py @@ -19,6 +19,8 @@ import sys import threading import time +import argparse +import shutil from flask import Flask from flask import request @@ -44,9 +46,45 @@ logger = logging.getLogger('Proxy') logger.debug("PATH: " + path) +#Create Proxy configuration file path +proxyConfigPath = os.path.join(path, "proxy.ini") + +# Command line input +parser = argparse.ArgumentParser(description='Proxy application interfaces a Faraday radio over USB UART') +parser.add_argument('--init-config', dest='init', action='store_true', help='Initialize Proxy application') +parser.add_argument('--config', action='store_true', help='Configure Proxy application') +parser.add_argument('--callsign', default='NOCALL', help='Faraday Callsign') +parser.add_argument('--nodeid', type=int, default=0, help='Faraday Node ID') +parser.add_argument('--port', default='COM1', help='Faraday UART port') +args = parser.parse_args() +print args + + +def initializeProxyConfig(init): + print "initializing proxy" + print path + shutil.copy(os.path.join(path,"proxy.sample.ini"),os.path.join(path,"proxy.ini")) + +def configureProxy(args,proxyConfigPath): + config = ConfigParser.RawConfigParser() + config.read(os.path.join(path, "proxy.ini")) + config.set('UNIT0', 'CALLSIGN', args.callsign) + config.set('UNIT0', 'NODEID', args.nodeid) + config.set('UNIT0', 'COM', args.port) + with open(proxyConfigPath, 'wb') as configfile: + config.write(configfile) + +if args.init: + initializeProxyConfig(args.init) + +if args.config: + configureProxy(args,proxyConfigPath) + # Load Proxy Configuration from proxy.ini file proxyConfig = ConfigParser.RawConfigParser() -proxyConfig.read(os.path.join(path, "proxy.ini")) + +proxyConfig.read(proxyConfigPath) + # Create and initialize dictionary queues postDict = {} diff --git a/requirements.txt b/requirements.txt index aef09f8a..469577e0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ appdirs==1.4.3 +argparse==1.4.0 click==6.7 configparser==3.5.0 enum34==1.1.6 From ab7bac8e8262d24f2cc379b7a26762ba3dfa124e Mon Sep 17 00:00:00 2001 From: kb1lqc Date: Sun, 28 May 2017 21:19:54 -0700 Subject: [PATCH 33/48] Updated configuration commands Removed need for --config command line and also removed defaults so that I can detect None values and ignore. Added baudrate and timeout values too. --- faraday/proxy.py | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/faraday/proxy.py b/faraday/proxy.py index 49a12979..09b71571 100644 --- a/faraday/proxy.py +++ b/faraday/proxy.py @@ -51,34 +51,38 @@ # Command line input parser = argparse.ArgumentParser(description='Proxy application interfaces a Faraday radio over USB UART') -parser.add_argument('--init-config', dest='init', action='store_true', help='Initialize Proxy application') -parser.add_argument('--config', action='store_true', help='Configure Proxy application') -parser.add_argument('--callsign', default='NOCALL', help='Faraday Callsign') -parser.add_argument('--nodeid', type=int, default=0, help='Faraday Node ID') -parser.add_argument('--port', default='COM1', help='Faraday UART port') +parser.add_argument('--init-config', dest='init', action='store_true', help='Initialize Proxy configuration file') +parser.add_argument('--callsign', help='Set Faraday callsign') +parser.add_argument('--nodeid', type=int, help='Set Faraday node ID') +parser.add_argument('--port', help='Set Faraday UART port') +parser.add_argument('--baudrate', help='Set Faraday UART baudrate') +parser.add_argument('--timeout', help='Set Faraday UART timeout') args = parser.parse_args() print args def initializeProxyConfig(init): - print "initializing proxy" - print path + logger.info("Initializing Proxy") shutil.copy(os.path.join(path,"proxy.sample.ini"),os.path.join(path,"proxy.ini")) + logger.info("Initialization complete") + sys.exit(0) def configureProxy(args,proxyConfigPath): config = ConfigParser.RawConfigParser() config.read(os.path.join(path, "proxy.ini")) - config.set('UNIT0', 'CALLSIGN', args.callsign) - config.set('UNIT0', 'NODEID', args.nodeid) - config.set('UNIT0', 'COM', args.port) + if args.callsign is not None: + config.set('UNIT0', 'CALLSIGN', args.callsign) + if args.nodeid is not None: + config.set('UNIT0', 'NODEID', args.nodeid) + if args.port is not None: + config.set('UNIT0', 'COM', args.port) with open(proxyConfigPath, 'wb') as configfile: config.write(configfile) if args.init: initializeProxyConfig(args.init) -if args.config: - configureProxy(args,proxyConfigPath) +configureProxy(args,proxyConfigPath) # Load Proxy Configuration from proxy.ini file proxyConfig = ConfigParser.RawConfigParser() From 29ed120ed2af0db8cc3b16e3f5f7daa0de1035ba Mon Sep 17 00:00:00 2001 From: kb1lqc Date: Sun, 28 May 2017 21:23:07 -0700 Subject: [PATCH 34/48] Updated proxy.py for PEP8 Performed pytest to check for currently used PEP8 rules. Fixed errors/warnings. --- faraday/proxy.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/faraday/proxy.py b/faraday/proxy.py index 09b71571..75698911 100644 --- a/faraday/proxy.py +++ b/faraday/proxy.py @@ -63,11 +63,12 @@ def initializeProxyConfig(init): logger.info("Initializing Proxy") - shutil.copy(os.path.join(path,"proxy.sample.ini"),os.path.join(path,"proxy.ini")) + shutil.copy(os.path.join(path, "proxy.sample.ini"), os.path.join(path, "proxy.ini")) logger.info("Initialization complete") sys.exit(0) -def configureProxy(args,proxyConfigPath): + +def configureProxy(args, proxyConfigPath): config = ConfigParser.RawConfigParser() config.read(os.path.join(path, "proxy.ini")) if args.callsign is not None: @@ -79,10 +80,11 @@ def configureProxy(args,proxyConfigPath): with open(proxyConfigPath, 'wb') as configfile: config.write(configfile) + if args.init: initializeProxyConfig(args.init) -configureProxy(args,proxyConfigPath) +configureProxy(args, proxyConfigPath) # Load Proxy Configuration from proxy.ini file proxyConfig = ConfigParser.RawConfigParser() From 302315ce928137108f9313d7004e01886a3f8181 Mon Sep 17 00:00:00 2001 From: kb1lqc Date: Sun, 28 May 2017 21:45:29 -0700 Subject: [PATCH 35/48] Updated configuration for second radio Allows configuration of second or higher radio. Can specify the zero indexed radio number. If the section does not exist it will be created in proxy.ini. --- faraday/proxy.py | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/faraday/proxy.py b/faraday/proxy.py index 75698911..ceead20d 100644 --- a/faraday/proxy.py +++ b/faraday/proxy.py @@ -55,8 +55,9 @@ parser.add_argument('--callsign', help='Set Faraday callsign') parser.add_argument('--nodeid', type=int, help='Set Faraday node ID') parser.add_argument('--port', help='Set Faraday UART port') -parser.add_argument('--baudrate', help='Set Faraday UART baudrate') -parser.add_argument('--timeout', help='Set Faraday UART timeout') +parser.add_argument('--baudrate', default='115200', help='Set Faraday UART baudrate') +parser.add_argument('--timeout', type=int, default=5, help='Set Faraday UART timeout') +parser.add_argument('--unit', type=int, default=0, help='Specify Faraday unit to configure') args = parser.parse_args() print args @@ -71,12 +72,27 @@ def initializeProxyConfig(init): def configureProxy(args, proxyConfigPath): config = ConfigParser.RawConfigParser() config.read(os.path.join(path, "proxy.ini")) + + # Set unit to configure + unit = 'UNIT' + str(args.unit) + print "UNIT: ", unit + if args.unit is not 0: + try: + config.add_section(unit) + + except ConfigParser.DuplicateSectionError: + pass + if args.callsign is not None: - config.set('UNIT0', 'CALLSIGN', args.callsign) + config.set(unit, 'CALLSIGN', args.callsign) if args.nodeid is not None: - config.set('UNIT0', 'NODEID', args.nodeid) + config.set(unit, 'NODEID', args.nodeid) if args.port is not None: - config.set('UNIT0', 'COM', args.port) + config.set(unit, 'COM', args.port) + if args.baudrate: + config.set(unit, 'BAUDRATE', args.baudrate) + if args.timeout: + config.set(unit, 'TIMEOUT', args.timeout) with open(proxyConfigPath, 'wb') as configfile: config.write(configfile) From e06e970ae1bc40efd6bd81373c3664aaafd7fa11 Mon Sep 17 00:00:00 2001 From: kb1lqc Date: Sun, 28 May 2017 21:50:59 -0700 Subject: [PATCH 36/48] Started proxy section configuration Allows configuration of number of units to use. --- faraday/proxy.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/faraday/proxy.py b/faraday/proxy.py index ceead20d..30303511 100644 --- a/faraday/proxy.py +++ b/faraday/proxy.py @@ -58,6 +58,7 @@ parser.add_argument('--baudrate', default='115200', help='Set Faraday UART baudrate') parser.add_argument('--timeout', type=int, default=5, help='Set Faraday UART timeout') parser.add_argument('--unit', type=int, default=0, help='Specify Faraday unit to configure') +parser.add_argument('-n', '--number', type=int, default=0, help='Set number of Faraday radios to use') args = parser.parse_args() print args @@ -73,9 +74,8 @@ def configureProxy(args, proxyConfigPath): config = ConfigParser.RawConfigParser() config.read(os.path.join(path, "proxy.ini")) - # Set unit to configure + # Configure UNITx sections unit = 'UNIT' + str(args.unit) - print "UNIT: ", unit if args.unit is not 0: try: config.add_section(unit) @@ -93,6 +93,11 @@ def configureProxy(args, proxyConfigPath): config.set(unit, 'BAUDRATE', args.baudrate) if args.timeout: config.set(unit, 'TIMEOUT', args.timeout) + + # Configure Proxy section items + if args.number is not 0: + config.set('PROXY', 'units', args.number) + with open(proxyConfigPath, 'wb') as configfile: config.write(configfile) From a09c0061cb5a4d4773505968265b40a834e9682e Mon Sep 17 00:00:00 2001 From: kb1lqc Date: Sun, 28 May 2017 23:21:20 -0700 Subject: [PATCH 37/48] Command line configuration of entire proxy config Manually tested all options of faraday proxy configuration via command line. All works as expected. Very basic implementation. --- faraday/proxy.py | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/faraday/proxy.py b/faraday/proxy.py index 30303511..725e4e5a 100644 --- a/faraday/proxy.py +++ b/faraday/proxy.py @@ -58,7 +58,25 @@ parser.add_argument('--baudrate', default='115200', help='Set Faraday UART baudrate') parser.add_argument('--timeout', type=int, default=5, help='Set Faraday UART timeout') parser.add_argument('--unit', type=int, default=0, help='Specify Faraday unit to configure') -parser.add_argument('-n', '--number', type=int, default=0, help='Set number of Faraday radios to use') + +#Proxy options +parser.add_argument('--number', type=int, default=0, help='Set number of Faraday radios to use') +parser.add_argument('--log', action='store_true', help='Set Proxy into logging mode') +parser.add_argument('--test-mode', dest='testmode', action='store_true', help='Set Proxy into test mode') +parser.add_argument('--test-callsign', dest='testcallsign', help='Set Faraday test mode callsign') +parser.add_argument('--test-nodeid', dest='testnodeid', type=int, help='Set Faraday test mode nodeid') +parser.add_argument('--test-rate', dest='testrate', default=1, type=int, help='Set Faraday test mode rate') + +# Proxy database options +parser.add_argument('--database', help='Set Faraday Proxy database') +parser.add_argument('--schema', help='Set Faraday database schema') +parser.add_argument('--test-database', dest='testdatabase', help='Set Faraday test mode database') + +# Proxy Flask options +parser.add_argument('--flask-host', dest='flaskhost', help='Set Faraday Flask server host address') +parser.add_argument('--flask-port', type=int, dest='flaskport', help='Set Faraday Flask server port') + + args = parser.parse_args() print args @@ -97,6 +115,34 @@ def configureProxy(args, proxyConfigPath): # Configure Proxy section items if args.number is not 0: config.set('PROXY', 'units', args.number) + if args.log: + config.set('PROXY', 'log', 1) + else: + config.set('PROXY', 'log', 0) + if args.testmode: + config.set('PROXY', 'testmode', 1) + else: + config.set('PROXY', 'testmode', 0) + if args.testcallsign is not None: + config.set('PROXY', 'testcallsign', args.testcallsign) + if args.testnodeid is not None: + config.set('PROXY', 'testnodeid', args.testnodeid) + if args.testrate: + config.set('PROXY', 'testrate', args.testrate) + + #Configure Proxy databases + if args.database is not None: + config.set('DATABASE', 'filename', args.database) + if args.schema is not None: + config.set('DATABASE', 'schemaname', args.schema) + if args.testdatabase is not None: + config.set('TESTDATABASE', 'filename', args.testdatabase) + + # Configure Proxy flask server + if args.flaskhost is not None: + config.set('FLASK', 'host', args.flaskhost) + if args.flaskport is not None: + config.set('FLASK', 'port', args.flaskport) with open(proxyConfigPath, 'wb') as configfile: config.write(configfile) From 50d3c7638c53b2d8e12a95c1fc2defbfd1772830 Mon Sep 17 00:00:00 2001 From: kb1lqc Date: Sun, 28 May 2017 23:43:32 -0700 Subject: [PATCH 38/48] Implemented Proxy log initialization Command line deletion of the old log file is now possible. --- faraday/proxy.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/faraday/proxy.py b/faraday/proxy.py index 725e4e5a..a8f34033 100644 --- a/faraday/proxy.py +++ b/faraday/proxy.py @@ -71,6 +71,7 @@ parser.add_argument('--database', help='Set Faraday Proxy database') parser.add_argument('--schema', help='Set Faraday database schema') parser.add_argument('--test-database', dest='testdatabase', help='Set Faraday test mode database') +parser.add_argument('--init-log', dest='initlog', action='store_true', help='Initialize Proxy log database') # Proxy Flask options parser.add_argument('--flask-host', dest='flaskhost', help='Set Faraday Flask server host address') @@ -78,8 +79,6 @@ args = parser.parse_args() -print args - def initializeProxyConfig(init): logger.info("Initializing Proxy") @@ -87,6 +86,14 @@ def initializeProxyConfig(init): logger.info("Initialization complete") sys.exit(0) +def initializeProxyLog(initlog, config): + logger.info("Initializing Proxy Log File") + log = config.get("DATABASE", "filename") + logpath = os.path.join(os.path.expanduser('~'), '.faraday', 'lib', log) + os.remove(logpath) + logger.info("Log initialization complete") + + def configureProxy(args, proxyConfigPath): config = ConfigParser.RawConfigParser() @@ -144,10 +151,12 @@ def configureProxy(args, proxyConfigPath): if args.flaskport is not None: config.set('FLASK', 'port', args.flaskport) + + with open(proxyConfigPath, 'wb') as configfile: config.write(configfile) - +# Initialize proxy if args.init: initializeProxyConfig(args.init) @@ -155,9 +164,12 @@ def configureProxy(args, proxyConfigPath): # Load Proxy Configuration from proxy.ini file proxyConfig = ConfigParser.RawConfigParser() - proxyConfig.read(proxyConfigPath) +# Initialize Proxy log database +if args.initlog: + initializeProxyLog(args.initlog, proxyConfig) + # Create and initialize dictionary queues postDict = {} From 264690851bc070d2a4f7da8f776c18f0aaf7dbda Mon Sep 17 00:00:00 2001 From: kb1lqc Date: Mon, 29 May 2017 00:02:12 -0700 Subject: [PATCH 39/48] Added support for moving and showing logs Proxy now initializes, moves, and lists all log files in the user/.faraday/lib directory from command line. --- faraday/proxy.py | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/faraday/proxy.py b/faraday/proxy.py index a8f34033..0a7eacc1 100644 --- a/faraday/proxy.py +++ b/faraday/proxy.py @@ -72,6 +72,8 @@ parser.add_argument('--schema', help='Set Faraday database schema') parser.add_argument('--test-database', dest='testdatabase', help='Set Faraday test mode database') parser.add_argument('--init-log', dest='initlog', action='store_true', help='Initialize Proxy log database') +parser.add_argument('--save-log', dest='savelog', help='Save Proxy log database into new SAVELOG file') +parser.add_argument('--showlogs', action='store_true', help='Show Proxy log database files') # Proxy Flask options parser.add_argument('--flask-host', dest='flaskhost', help='Set Faraday Flask server host address') @@ -86,14 +88,27 @@ def initializeProxyConfig(init): logger.info("Initialization complete") sys.exit(0) -def initializeProxyLog(initlog, config): +def initializeProxyLog(config): logger.info("Initializing Proxy Log File") log = config.get("DATABASE", "filename") logpath = os.path.join(os.path.expanduser('~'), '.faraday', 'lib', log) os.remove(logpath) logger.info("Log initialization complete") +def saveProxyLog(name, config): + log = config.get("DATABASE", "filename") + oldpath = os.path.join(os.path.expanduser('~'), '.faraday', 'lib', log) + newpath = os.path.join(os.path.expanduser('~'), '.faraday', 'lib', name) + shutil.move(oldpath,newpath) + sys.exit(0) +def showProxyLogs(): + logger.info("The following logs exist for Proxy...") + path = os.path.join(os.path.expanduser('~'), '.faraday', 'lib') + for file in os.listdir(path): + if file.endswith(".db"): + logger.info(file) + sys.exit(0) def configureProxy(args, proxyConfigPath): config = ConfigParser.RawConfigParser() @@ -168,7 +183,15 @@ def configureProxy(args, proxyConfigPath): # Initialize Proxy log database if args.initlog: - initializeProxyLog(args.initlog, proxyConfig) + initializeProxyLog(proxyConfig) + +# Save Proxy log database +if args.savelog is not None: + saveProxyLog(args.savelog, proxyConfig) + +# List Proxy log database files +if args.showlogs: + showProxyLogs() # Create and initialize dictionary queues From b6e8981eb7abfa4022a8b2888ab2c74edaf375f1 Mon Sep 17 00:00:00 2001 From: kb1lqc Date: Mon, 29 May 2017 00:11:08 -0700 Subject: [PATCH 40/48] Updated docstrings for command line functions Updated docstrings for new functions used in command line input configuration. Also, updated per pytest PEP8 warning/error messages. --- faraday/proxy.py | 53 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 45 insertions(+), 8 deletions(-) diff --git a/faraday/proxy.py b/faraday/proxy.py index 0a7eacc1..f1999648 100644 --- a/faraday/proxy.py +++ b/faraday/proxy.py @@ -79,30 +79,61 @@ parser.add_argument('--flask-host', dest='flaskhost', help='Set Faraday Flask server host address') parser.add_argument('--flask-port', type=int, dest='flaskport', help='Set Faraday Flask server port') - +# Parse the arguments args = parser.parse_args() -def initializeProxyConfig(init): + +def initializeProxyConfig(): + ''' + Initialize proxy configuration file from proxy.sample.ini + + :return: None, exits program + ''' + logger.info("Initializing Proxy") shutil.copy(os.path.join(path, "proxy.sample.ini"), os.path.join(path, "proxy.ini")) logger.info("Initialization complete") sys.exit(0) + def initializeProxyLog(config): + ''' + Initialize the log database by deleting file + + :param config: Proxy ConfigParser object from proxy.ini + :return: None + ''' + logger.info("Initializing Proxy Log File") log = config.get("DATABASE", "filename") logpath = os.path.join(os.path.expanduser('~'), '.faraday', 'lib', log) os.remove(logpath) logger.info("Log initialization complete") + def saveProxyLog(name, config): + ''' + Save proxy log database into a new file + + :param name: Name of file to save data into (should be .db) + :param config: Proxy ConfigParser object from proxy.ini + :return: None + ''' + log = config.get("DATABASE", "filename") oldpath = os.path.join(os.path.expanduser('~'), '.faraday', 'lib', log) newpath = os.path.join(os.path.expanduser('~'), '.faraday', 'lib', name) - shutil.move(oldpath,newpath) + shutil.move(oldpath, newpath) sys.exit(0) + def showProxyLogs(): + ''' + Show proxy log database filenames in user path ~/.faraday/lib folder + + :return: None, exits program + ''' + logger.info("The following logs exist for Proxy...") path = os.path.join(os.path.expanduser('~'), '.faraday', 'lib') for file in os.listdir(path): @@ -110,7 +141,16 @@ def showProxyLogs(): logger.info(file) sys.exit(0) + def configureProxy(args, proxyConfigPath): + ''' + Configure proxy configuration file from command line + + :param args: argparse arguments + :param proxyConfigPath: Path to proxy.ini file + :return: None + ''' + config = ConfigParser.RawConfigParser() config.read(os.path.join(path, "proxy.ini")) @@ -166,15 +206,13 @@ def configureProxy(args, proxyConfigPath): if args.flaskport is not None: config.set('FLASK', 'port', args.flaskport) - - with open(proxyConfigPath, 'wb') as configfile: config.write(configfile) -# Initialize proxy + +# Initialize and configure proxy if args.init: initializeProxyConfig(args.init) - configureProxy(args, proxyConfigPath) # Load Proxy Configuration from proxy.ini file @@ -193,7 +231,6 @@ def configureProxy(args, proxyConfigPath): if args.showlogs: showProxyLogs() - # Create and initialize dictionary queues postDict = {} postDicts = {} From a8451af74e9a4bec23ba4e4d4b02a97ef2c7e534 Mon Sep 17 00:00:00 2001 From: kb1lqc Date: Mon, 29 May 2017 00:34:31 -0700 Subject: [PATCH 41/48] Updated userpath for config files and setup rev Userpath was wrong for the initial config file load as I later found out and I updated this in retrospect. Also changed the program rev. --- faraday/proxy.py | 2 +- setup.cfg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/faraday/proxy.py b/faraday/proxy.py index f1999648..fa41b624 100644 --- a/faraday/proxy.py +++ b/faraday/proxy.py @@ -32,7 +32,7 @@ relpath1 = os.path.join('etc', 'faraday') relpath2 = os.path.join('..', 'etc', 'faraday') setuppath = os.path.join(sys.prefix, 'etc', 'faraday') -userpath = os.path.expanduser('~/.faraday') +userpath = os.path.join(os.path.expanduser('~'), '.faraday') path = '' for location in os.curdir, relpath1, relpath2, setuppath, userpath: diff --git a/setup.cfg b/setup.cfg index 02f969f7..805d0c17 100644 --- a/setup.cfg +++ b/setup.cfg @@ -10,7 +10,7 @@ summary = FaradayRF amateur radio open source software description-file = README home-page = https://github.com/FaradayRF/Faraday-Software license = GPLv3 -version = 0.0.1008 +version = 0.0.1009 classifier = "Development Status :: 2 - Pre-Alpha" "Framework :: Flask" From b6798b4e1bdf750798e0aa60226d41e26a411abe Mon Sep 17 00:00:00 2001 From: Brenton Salmi Date: Sat, 17 Jun 2017 19:25:06 -0700 Subject: [PATCH 42/48] Removed unneeded and failing argument line 215 proxy.py --- faraday/proxy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/faraday/proxy.py b/faraday/proxy.py index fa41b624..2feb30fb 100644 --- a/faraday/proxy.py +++ b/faraday/proxy.py @@ -212,7 +212,7 @@ def configureProxy(args, proxyConfigPath): # Initialize and configure proxy if args.init: - initializeProxyConfig(args.init) + initializeProxyConfig() configureProxy(args, proxyConfigPath) # Load Proxy Configuration from proxy.ini file From cfd406cb10f7c030665520614a39b3405416bf05 Mon Sep 17 00:00:00 2001 From: Bryce Salmi Date: Sun, 18 Jun 2017 15:46:39 -0700 Subject: [PATCH 43/48] Remove Unecessary setuptools options Not bothering making faraday-telemetry and other apps since we are only focusing on getting faraday-proxy to run correctly right now. --- setup.cfg | 3 --- 1 file changed, 3 deletions(-) diff --git a/setup.cfg b/setup.cfg index 805d0c17..b3e2cac5 100644 --- a/setup.cfg +++ b/setup.cfg @@ -48,6 +48,3 @@ data_files = [entry_points] console_scripts = faraday-proxy = faraday.proxy:main - faraday-telemetry = faraday.telemetry:main - faraday-aprs = faraday.aprs:main - faraday-simpleui = faraday.simpleui:main From 8d728542150e234ae719cc07288b88704c1b9693 Mon Sep 17 00:00:00 2001 From: Bryce Salmi Date: Sun, 18 Jun 2017 15:56:15 -0700 Subject: [PATCH 44/48] Update README with simple link to quickstart Keeping it simple for the README by linking to the quickstart tutorial which will be updated with correct installation instructions. --- README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README b/README index 1c9b3054..aa031ab3 100644 --- a/README +++ b/README @@ -1 +1 @@ -faradayrf \ No newline at end of file +For installation instructions please visit https://github.com/FaradayRF/Faraday-Software/tree/master/Tutorials/start \ No newline at end of file From e6e382f43efe60163a28d3ad98738d3eb746d8ae Mon Sep 17 00:00:00 2001 From: Bryce Salmi Date: Sun, 18 Jun 2017 16:12:04 -0700 Subject: [PATCH 45/48] Changed proxy.ini path to logger Performing a logging debug message of the proxy.ini path instead of a print. --- faraday/proxy.py | 1 + 1 file changed, 1 insertion(+) diff --git a/faraday/proxy.py b/faraday/proxy.py index 2feb30fb..be135c06 100644 --- a/faraday/proxy.py +++ b/faraday/proxy.py @@ -48,6 +48,7 @@ #Create Proxy configuration file path proxyConfigPath = os.path.join(path, "proxy.ini") +logger.debug('Proxy.ini PATH: ', proxyConfigPath) # Command line input parser = argparse.ArgumentParser(description='Proxy application interfaces a Faraday radio over USB UART') From 01bf0bb79e5855184738539d777b23d17adfd9a2 Mon Sep 17 00:00:00 2001 From: Bryce Salmi Date: Sun, 18 Jun 2017 17:55:50 -0700 Subject: [PATCH 46/48] Removed unecessary path print and fixed logging Corrected erroneous comma instead of a plus sign for combining strings in a logging.debug() command. Also removed an extra an unneeded logging.debug() command. --- faraday/proxy.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/faraday/proxy.py b/faraday/proxy.py index be135c06..9015d06a 100644 --- a/faraday/proxy.py +++ b/faraday/proxy.py @@ -44,11 +44,10 @@ pass logger = logging.getLogger('Proxy') -logger.debug("PATH: " + path) #Create Proxy configuration file path proxyConfigPath = os.path.join(path, "proxy.ini") -logger.debug('Proxy.ini PATH: ', proxyConfigPath) +logger.debug('Proxy.ini PATH: ' + proxyConfigPath) # Command line input parser = argparse.ArgumentParser(description='Proxy application interfaces a Faraday radio over USB UART') From bf66c04ae544525022622897cd7e97ada1b1b62e Mon Sep 17 00:00:00 2001 From: Bryce Salmi Date: Sun, 18 Jun 2017 18:47:26 -0700 Subject: [PATCH 47/48] Removed unecesary argparse requirement It's part of stdlib in Python >2.6 so it's already there. --- requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 469577e0..aef09f8a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,4 @@ appdirs==1.4.3 -argparse==1.4.0 click==6.7 configparser==3.5.0 enum34==1.1.6 From 13746c091bc0818d42189c42e1abbb4279544611 Mon Sep 17 00:00:00 2001 From: Bryce Salmi Date: Sun, 18 Jun 2017 18:48:45 -0700 Subject: [PATCH 48/48] Changed version in setup.cfg Needed to change it so that uploading to PyPi works. However it should be oding this by commit anywyas so might not be needed but hell... Let's start on 0.0.1010 with this PR. For funzies. --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index b3e2cac5..5132c800 100644 --- a/setup.cfg +++ b/setup.cfg @@ -10,7 +10,7 @@ summary = FaradayRF amateur radio open source software description-file = README home-page = https://github.com/FaradayRF/Faraday-Software license = GPLv3 -version = 0.0.1009 +version = 0.0.1010 classifier = "Development Status :: 2 - Pre-Alpha" "Framework :: Flask"