From 55f27e3b965acb0aba419fb2fa7aadafa4e401a7 Mon Sep 17 00:00:00 2001 From: Thomas Willson Date: Tue, 23 Jul 2024 14:18:42 -0700 Subject: [PATCH] Add CI +semver-set:1.0.0+0 --- .github/workflows/build_tag.yml | 46 ++++++++++++++ .gitignore | 3 +- .python-version | 1 + .vscode/.ropeproject/config.py | 100 ----------------------------- .vscode/.ropeproject/objectdb | Bin 213 -> 0 bytes .vscode/launch.json | 107 -------------------------------- .vscode/settings.json | 9 --- bin/example.py | 55 +++++++++++----- example.spec | 37 +++++++++++ requirements.txt | 2 + 10 files changed, 127 insertions(+), 233 deletions(-) create mode 100644 .github/workflows/build_tag.yml create mode 100644 .python-version delete mode 100644 .vscode/.ropeproject/config.py delete mode 100644 .vscode/.ropeproject/objectdb delete mode 100644 .vscode/launch.json delete mode 100644 .vscode/settings.json create mode 100644 example.spec create mode 100644 requirements.txt diff --git a/.github/workflows/build_tag.yml b/.github/workflows/build_tag.yml new file mode 100644 index 0000000..4e865b2 --- /dev/null +++ b/.github/workflows/build_tag.yml @@ -0,0 +1,46 @@ +name: Build and Tag +on: + push: + branches: [master] + pull_request: +jobs: + build-exe: + strategy: + fail-fast: false + matrix: + python-version: [2.7] + os: [windows-latest, macos-latest, ubuntu-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + - name: Determine Version + id: staflversion + uses: StaflSystems/CustomGithubActions/DetermineVersion@main + - name: Display Version + run: | + echo "Version: ${{steps.staflversion.outputs.full}}" + - name: Build Executable + if: runner.os == 'windows' + run: | + pyinstaller --clean example.spec + - name: Build Executable + if: runner.os != 'windows' + run: | + pyinstaller --clean example.spec + cd dist + find . -wholename "*${{ steps.staflversion.outputs.full }}*" -exec sh -c 'mv "$1" "$1_${{ matrix.os }}"' _ {} \; + cd .. + - name: Create a GitHub release + if: github.ref == 'refs/heads/main' + uses: ncipollo/release-action@v1 + with: + artifacts: dist/* + tag: ${{ steps.staflversion.outputs.full }} + allowUpdates: true diff --git a/.gitignore b/.gitignore index c472415..08855ef 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ /*.egg-info /*.egg /build/ -.vscode/ \ No newline at end of file +.vscode/ +**/__pycache__ \ No newline at end of file diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..a616492 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +2.7.18 diff --git a/.vscode/.ropeproject/config.py b/.vscode/.ropeproject/config.py deleted file mode 100644 index d1e8f3d..0000000 --- a/.vscode/.ropeproject/config.py +++ /dev/null @@ -1,100 +0,0 @@ -# The default ``config.py`` -# flake8: noqa - - -def set_prefs(prefs): - """This function is called before opening the project""" - - # Specify which files and folders to ignore in the project. - # Changes to ignored resources are not added to the history and - # VCSs. Also they are not returned in `Project.get_files()`. - # Note that ``?`` and ``*`` match all characters but slashes. - # '*.pyc': matches 'test.pyc' and 'pkg/test.pyc' - # 'mod*.pyc': matches 'test/mod1.pyc' but not 'mod/1.pyc' - # '.svn': matches 'pkg/.svn' and all of its children - # 'build/*.o': matches 'build/lib.o' but not 'build/sub/lib.o' - # 'build//*.o': matches 'build/lib.o' and 'build/sub/lib.o' - prefs['ignored_resources'] = ['*.pyc', '*~', '.ropeproject', - '.hg', '.svn', '_svn', '.git', '.tox'] - - # Specifies which files should be considered python files. It is - # useful when you have scripts inside your project. Only files - # ending with ``.py`` are considered to be python files by - # default. - #prefs['python_files'] = ['*.py'] - - # Custom source folders: By default rope searches the project - # for finding source folders (folders that should be searched - # for finding modules). You can add paths to that list. Note - # that rope guesses project source folders correctly most of the - # time; use this if you have any problems. - # The folders should be relative to project root and use '/' for - # separating folders regardless of the platform rope is running on. - # 'src/my_source_folder' for instance. - #prefs.add('source_folders', 'src') - - # You can extend python path for looking up modules - #prefs.add('python_path', '~/python/') - - # Should rope save object information or not. - prefs['save_objectdb'] = True - prefs['compress_objectdb'] = False - - # If `True`, rope analyzes each module when it is being saved. - prefs['automatic_soa'] = True - # The depth of calls to follow in static object analysis - prefs['soa_followed_calls'] = 0 - - # If `False` when running modules or unit tests "dynamic object - # analysis" is turned off. This makes them much faster. - prefs['perform_doa'] = True - - # Rope can check the validity of its object DB when running. - prefs['validate_objectdb'] = True - - # How many undos to hold? - prefs['max_history_items'] = 32 - - # Shows whether to save history across sessions. - prefs['save_history'] = True - prefs['compress_history'] = False - - # Set the number spaces used for indenting. According to - # :PEP:`8`, it is best to use 4 spaces. Since most of rope's - # unit-tests use 4 spaces it is more reliable, too. - prefs['indent_size'] = 4 - - # Builtin and c-extension modules that are allowed to be imported - # and inspected by rope. - prefs['extension_modules'] = [] - - # Add all standard c-extensions to extension_modules list. - prefs['import_dynload_stdmods'] = True - - # If `True` modules with syntax errors are considered to be empty. - # The default value is `False`; When `False` syntax errors raise - # `rope.base.exceptions.ModuleSyntaxError` exception. - prefs['ignore_syntax_errors'] = False - - # If `True`, rope ignores unresolvable imports. Otherwise, they - # appear in the importing namespace. - prefs['ignore_bad_imports'] = False - - # If `True`, rope will insert new module imports as - # `from import ` by default. - prefs['prefer_module_from_imports'] = False - - # If `True`, rope will transform a comma list of imports into - # multiple separate import statements when organizing - # imports. - prefs['split_imports'] = False - - # If `True`, rope will sort imports alphabetically by module name - # instead of alphabetically by import statement, with from imports - # after normal imports. - prefs['sort_imports_alphabetically'] = False - - -def project_opened(project): - """This function is called after opening the project""" - # Do whatever you like here! diff --git a/.vscode/.ropeproject/objectdb b/.vscode/.ropeproject/objectdb deleted file mode 100644 index 51ac1c9ea4fc0a76ebfb99c46aab88b40d2b2e8a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 213 zcmXAiy>7xV6h^~e0|814TNh>)^AMSkTB%a8#D?tn(pZpdK06W05UCv+Ub~T)j?P)m zPrpHQSVvKm=Bm)-Q^!nM`EIpWzTOtj=qiY7jb4MkeEWE~CuNSgyBN#g$58qX7-ZgE zNoW;FI4cS&oUe^ezOpXw_~a4{H@_G)c#>nwp;Vj^Vi_AcStf&V-jkEZV4r?sa!1l) nD&vaJ>~4(NALjY|j%OL`%3ey#Sja(l$4iUX&|ukOr9%+^!T?Dh diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index 39881c1..0000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,107 +0,0 @@ -{ - "version": "0.2.0", - "configurations": [ - { - "name": "Python", - "type": "python", - "request": "launch", - "stopOnEntry": false, - "pythonPath": "${config:python.pythonPath}", - "program": "${file}", - "cwd": "${workspaceRoot}", - "env": {}, - "envFile": "${workspaceRoot}/.env", - "debugOptions": [ - "WaitOnAbnormalExit", - "WaitOnNormalExit", - "RedirectOutput" - ] - }, - { - "name": "Integrated Terminal/Console", - "type": "python", - "request": "launch", - "stopOnEntry": true, - "pythonPath": "${config.python.pythonPath}", - "program": "${file}", - "console": "integratedTerminal", - "debugOptions": [ - "WaitOnAbnormalExit", - "WaitOnNormalExit" - ] - }, - { - "name": "External Terminal/Console", - "type": "python", - "request": "launch", - "stopOnEntry": true, - "pythonPath": "${config.python.pythonPath}", - "program": "${file}", - "console": "externalTerminal", - "debugOptions": [ - "WaitOnAbnormalExit", - "WaitOnNormalExit" - ] - }, - { - "name": "Django", - "type": "python", - "request": "launch", - "stopOnEntry": true, - "pythonPath": "${config.python.pythonPath}", - "program": "${workspaceRoot}/manage.py", - "args": [ - "runserver", - "--noreload" - ], - "debugOptions": [ - "WaitOnAbnormalExit", - "WaitOnNormalExit", - "RedirectOutput", - "DjangoDebugging" - ] - }, - { - "name": "Flask", - "type": "python", - "request": "launch", - "stopOnEntry": true, - "pythonPath": "${config.python.pythonPath}", - "program": "${workspaceRoot}/run.py", - "args": [], - "debugOptions": [ - "WaitOnAbnormalExit", - "WaitOnNormalExit", - "RedirectOutput" - ] - }, - { - "name": "Watson", - "type": "python", - "request": "launch", - "stopOnEntry": true, - "pythonPath": "${config.python.pythonPath}", - "program": "${workspaceRoot}/console.py", - "args": [ - "dev", - "runserver", - "--noreload=True" - ], - "debugOptions": [ - "WaitOnAbnormalExit", - "WaitOnNormalExit", - "RedirectOutput" - ] - }, - { - "name": "Attach (Remote Debug)", - "type": "python", - "request": "attach", - "localRoot": "${workspaceRoot}", - "remoteRoot": "${workspaceRoot}", - "port": 3000, - "secret": "my_secret", - "host": "localhost" - } - ] -} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 25edfbf..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,9 +0,0 @@ -// Place your settings in this file to overwrite default and user settings. -{ - "python.pythonPath": "C:/Python27/python.exe", - "python.autoComplete.extraPaths": [ - "${env.SPARK_HOME}\\python", - "${env.SPARK_HOME}\\python\\pyspark" - ], - "python.linting.pylintPath": "c:/Python27/Scripts/pylint.exe" -} \ No newline at end of file diff --git a/bin/example.py b/bin/example.py index 0791008..4f37907 100644 --- a/bin/example.py +++ b/bin/example.py @@ -3,29 +3,31 @@ ''' import pprint import time +import signal + from chamberconnectlibrary.watlowf4t import WatlowF4T from chamberconnectlibrary.watlowf4 import WatlowF4 from chamberconnectlibrary.espec import Espec LOOP_NAMES = ['Temperature', 'Humidity'] -CONTROLLER = Espec( - interface='Serial', - serialport='//./COM10', - baudrate=19200, - loop_names=LOOP_NAMES -) +# CONTROLLER = Espec( +# interface='Serial', +# serialport='//./COM10', +# baudrate=19200, +# loop_names=LOOP_NAMES +# ) # CONTROLLER = WatlowF4( # interface='RTU', # serialport='//./COM7', # baudrate=19200, # loop_names=LOOP_NAMES # ) -# CONTROLLER = WatlowF4T( -# interface='TCP', -# host='10.30.100.138', -# loop_names=LOOP_NAMES -# ) +CONTROLLER = WatlowF4T( + interface='TCP', + host='10.10.1.205', + loop_names=LOOP_NAMES +) # CONTROLLER = WatlowF4T( # interface='RTU', # serialport='//./COM4', @@ -57,14 +59,35 @@ # for i in range(8): # print CONTROLLER.get_event(i+1) -for _ in range(100): - print '\nsample' +running = True + + + +file = open('data.csv', 'w+', 0) +file.write('timestamp,temperature setpoint (C),temperature current (C),humidity setpoint (%RH),humidity current (%RH)\n') + +def signal_handler(signal, frame): + global running + running = False + +signal.signal(signal.SIGINT, signal_handler) + +while running: stm = time.time() lookup = {'cascade':[], 'loop':[]} lookup['loop'].append({'name':'Temperature', 'id': 1, 'number': 1}) lookup['loop'].append({'name':'Humidity', 'id': 2, 'number': 2}) - params = {'get_loops':True, 'get_status':True, 'get_alarms':True, 'get_program_status':True, 'get_program_list':True, 'get_refrig':True} + params = {'get_loops':True, 'get_status':True, 'get_alarms':True, 'get_program_status':True, 'get_program_list':False, 'get_refrig':True} params['get_events'] = [{'N':i+1, 'name':'TS#%d'%(i+1)} for i in range(8)] smpl = CONTROLLER.sample(lookup, **params) - print("--- %s seconds ---" % (time.time() - stm)) - print(smpl) + + pprint.pprint(smpl) + + if len(smpl['loops']) < 2: + continue + + print(",") + file.write("%s,%s,%s,%s,%s\n" % (time.strftime('%Y-%m-%d %H:%M:%S'), smpl['loops'][0]['setpoint']['current'], smpl['loops'][0]['processvalue']['air'], smpl['loops'][1]['setpoint']['current'], smpl['loops'][1]['processvalue']['air'])) + +file.close() +CONTROLLER.close() diff --git a/example.spec b/example.spec new file mode 100644 index 0000000..ea96d99 --- /dev/null +++ b/example.spec @@ -0,0 +1,37 @@ +# -*- mode: python ; coding: utf-8 -*- + +block_cipher = None + + +a = Analysis(['bin/example.py'], + pathex=['.'], + binaries=[], + datas=[], + hiddenimports=[], + hookspath=[], + runtime_hooks=[], + excludes=[], + win_no_prefer_redirects=False, + win_private_assemblies=False, + cipher=block_cipher, + noarchive=False) +pyz = PYZ(a.pure, a.zipped_data, + cipher=block_cipher) +exe = EXE(pyz, + a.scripts, + [], + exclude_binaries=True, + name='chamber_logger', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + console=True ) +coll = COLLECT(exe, + a.binaries, + a.zipfiles, + a.datas, + strip=False, + upx=True, + upx_exclude=[], + name='chamber_logger') diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..683c567 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +chamberconnectlibrary +pyinstaller \ No newline at end of file