Skip to content

Fix main for Python2#63

Merged
AlexanderWells-diamond merged 2 commits into
masterfrom
fix_python2_main
Nov 25, 2021
Merged

Fix main for Python2#63
AlexanderWells-diamond merged 2 commits into
masterfrom
fix_python2_main

Conversation

@AlexanderWells-diamond

@AlexanderWells-diamond AlexanderWells-diamond commented Nov 24, 2021

Copy link
Copy Markdown
Collaborator

Fix the main function for Python2. When this is merged a new release should be done.

Note the version import change is not strictly required, it's just a fix for cases when __main__ has been imported by someone else, which caused the import to pick up softioc.py instead of the module itself. This happens using virtualenv with its startup script.

Closes #62
Closes #59

@codecov

codecov Bot commented Nov 24, 2021

Copy link
Copy Markdown

Codecov Report

Merging #63 (5c39790) into master (dfc3971) will decrease coverage by 0.20%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #63      +/-   ##
==========================================
- Coverage   85.57%   85.37%   -0.21%     
==========================================
  Files          13       13              
  Lines         832      834       +2     
==========================================
  Hits          712      712              
- Misses        120      122       +2     
Impacted Files Coverage Δ
softioc/__main__.py 0.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dfc3971...5c39790. Read the comment docs.

@thomascobb

Copy link
Copy Markdown
Contributor

Please can we also make the script optional, so running pythonSoftIOC launches the executable with no args in a subprocess?

@thomascobb

Copy link
Copy Markdown
Contributor

That's #59, then the python2 support can be dropped

This restores previous behaviour of the pythonSoftIOC executable, which
would give you a Python command line interpreter.
@AlexanderWells-diamond

AlexanderWells-diamond commented Nov 25, 2021

Copy link
Copy Markdown
Collaborator Author

@thomascobb I've committed the fix for #59. Manual testing on the command line indicates it'll now pass everything, to a script. Used below is a simple test.py script that just prints sys.argv:

$ /pythonSoftIOC test.py
['test.py']
$ pythonSoftIOC test.py abc
['test.py', 'abc']
pythonSoftIOC test.py --abc
['test.py', '--abc']
$ pythonSoftIOC -i test.py
['test.py', '-i']
$ pythonSoftIOC -i
Python 3.7.2 (default, Jan 20 2020, 11:03:41) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()

@thomascobb

Copy link
Copy Markdown
Contributor

behaviour looks good, although I can't see the commit that adds this...

@AlexanderWells-diamond AlexanderWells-diamond merged commit 8c8fb1f into master Nov 25, 2021
@AlexanderWells-diamond AlexanderWells-diamond deleted the fix_python2_main branch November 25, 2021 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix Python2 main function Command line interface script should be optional

2 participants