Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Faraday-Proxy PyPi Support #203

Merged
merged 48 commits into from
Jun 19, 2017
Merged

Faraday-Proxy PyPi Support #203

merged 48 commits into from
Jun 19, 2017

Conversation

kb1lqc
Copy link
Member

@kb1lqc kb1lqc commented Jun 3, 2017

Related to Issue #191

This PR is intended to get the Proxy application into the pip index. It also allows for "editable" mode installation with command line operation of proxy.

This PR will definitely need some love before merging but it's a good starting point for discussion

Operation

Navigate to the main folder and pip install -e . to install in editable mode. One can also follow the python packaging guides to create an uploadable distribution for the PyPi servers.

Once installed simply run "Faraday-Proxy" to run the proxy program from command line.

You will need to configure the proxy application by first seeing the options by running faraday-proxy -h

First you will need to create a new configure file by running faraday-proxy --configure then run a second Faraday-Proxy command with the appropriate options to set the callsign, node Id, and port (usually comx on windiws).

This is the best I got for remembering from memory try to figure it out the best you can with the help options and then asking me the rest. I don't have access to the software as I'm traveling internationally at this time without a laptop!

kb1lqc added 30 commits April 30, 2017 15:02
Initial add of setup.py for setuptools use when installing with pip.
Added Faraday specific data into the setup.py file.
Removed test folder indicated in setup.py as well as changed the README to
REAMDE.md in the same file.
Still having 'pip install faraday' issues but it uploades to pypi!
Specified requirements in setup.py
Will move over to pbr and this requires a simplified setup.py.
Faraday-proxy appears to work. Now I need to fix the formatters ini filer
error per @hdmike.
Used @hdkmike suggested import code and the issue was fixed. Now I need to
do the same for proxy.ini.
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.
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.
Imported faraday/telemetry.py directly as well as fixed up paths to
configuration files and databases.
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.
Very simple update of logging file locations as well as setup.cfg to point
to the correct entry points.
Fixed data_file formatting and also forced a difference base version so I
can upload to pypi without committing.
Updated proxy.py to use configuration files from etc/ folder.
To ensure all files are in a common faraday folder.
updated file paths to enable use of /etc/faraday/
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.
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.
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!
Ran pytest and fixed the PEP8 errors/warnings.
@kb1lqd
Copy link
Contributor

kb1lqd commented Jun 4, 2017

faraday-proxy --configure is unrecognized

image

@reillyeon any thoughts?

@kb1lqd
Copy link
Contributor

kb1lqd commented Jun 4, 2017

Oh no, I think this is messing with all my other faraday branches I have checked out... I can run applications and such from other branches after install this PR... I need to uninstall to run any other heritage branches?

EDIT:

I needed to pip uninstall faraday to run any other GITHUB branches in our heritage fashion.

@el-iso
Copy link
Contributor

el-iso commented Jun 4, 2017 via email

@kb1lqc
Copy link
Member Author

kb1lqc commented Jun 5, 2017

Yes please do not use pip install Faraday at this time. In learning PyPi I uploaded a non working package to the main PyPi site instead of test PyPi. That version us very old and won't work. You must install editable or from PyPi test server.

However the PyPi test server will often fail on a fresh install since not all required packages have test PyPi uploads with the latest versions so you need to install thise from normal PyPi instead of test.

https://stackoverflow.com/a/34561435

This is the latest test PyPi which should be the same version in my git PR
https://testpypi.python.org/pypi/faraday/0.0.1009.dev988

Use the stack overflow method above to install from the test PyPi if you want. However I still suggest editable mode!

@kb1lqc
Copy link
Member Author

kb1lqc commented Jun 5, 2017

@kb1lqd @el-iso woops! --init-config is what you want to create the initial config file, sorry about the confusion!

After that runs you'll have a config file with REPLACEME placeholders. Then run in one or more command line entries

Faraday-Proxy --callsign CALLSIGN --nodeid NODEID --port PORT

Make sure you remember port is com port so COM5 or similar on Windows and dev/ttyusb or similar on Linux and mac

@kb1lqd
Copy link
Contributor

kb1lqd commented Jun 7, 2017

@kb1lqc

pip install -e . Looks to have successfully installed faraday:

image

I made sure to restart the command window just incase.

faraday-proxy --init-config fails!

image

It looks like it is not expecting arguments but getting them?

Also, I definitely could NOT run my RFDataport branch with this installed so I had to remove it again.

@kb1lqc
Copy link
Member Author

kb1lqc commented Jun 8, 2017

Hmm make sure you have the python module shutil though I think it comes with python anyways. That said weird, it's complaining that I passed the initial argument which should be true or false...

@kb1lqc
Copy link
Member Author

kb1lqc commented Jun 8, 2017

Yup @kb1lqd looks like line 86 of proxy.py clearly shows no arguments yet like 215 passes them. Not sure how this happened. Try modifying line 215 to remove the argument passed. Installed in editable mode literally means you can edit the file and try again, no need to re install

@kb1lqd
Copy link
Contributor

kb1lqd commented Jun 18, 2017

@kb1lqc @reillyeon I verified that Bryce's suggestion to remove line 215 argument in proxy.py worked and I can now run proxy as described:

image

@kb1lqc
Copy link
Member Author

kb1lqc commented Jun 18, 2017

Running the current commit b6798b4 results in the following error if not launched from the main folder. This test was performed by moving up one directory.

Bryce@BRYCE-SP4 MINGW64 ~/Documents/GitHub
$ faraday-proxy
Traceback (most recent call last):
  File "C:\Python27\Scripts\faraday-proxy-script.py", line 11, in <module>
    load_entry_point('faraday', 'console_scripts', 'faraday-proxy')()
  File "C:\python27\lib\site-packages\pkg_resources\__init__.py", line 560, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "C:\python27\lib\site-packages\pkg_resources\__init__.py", line 2648, in load_entry_point
    return ep.load()
  File "C:\python27\lib\site-packages\pkg_resources\__init__.py", line 2302, in load
    return self.resolve()
  File "C:\python27\lib\site-packages\pkg_resources\__init__.py", line 2308, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "c:\users\bryce\documents\github\faradayrf-kb1lqc\faraday\proxy.py", line 216, in <module>
    configureProxy(args, proxyConfigPath)
  File "c:\users\bryce\documents\github\faradayrf-kb1lqc\faraday\proxy.py", line 173, in configureProxy
    config.set(unit, 'BAUDRATE', args.baudrate)
  File "C:\python27\lib\ConfigParser.py", line 396, in set
    raise NoSectionError(section)
ConfigParser.NoSectionError: No section: 'UNIT0'

It appears that the code for finding proxy.ini is wrong and defaulting to the current directory.

kb1lqc added 3 commits June 18, 2017 15:46
Not bothering making faraday-telemetry and other apps since we are only
focusing on getting faraday-proxy to run correctly right now.
Keeping it simple for the README by linking to the quickstart tutorial
which will be updated with correct installation instructions.
Performing a logging debug message of the proxy.ini path instead of a
print.
@kb1lqc kb1lqc requested a review from kb1lqd June 18, 2017 23:13
path = location
break
except ConfigParser.NoSectionError:
pass
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I don't fail gracefully this code allows editable mode (or other installations) to fail if the file is never found. The code simply moves on with a blank path. Woops. This is related
to IT #206

faraday/proxy.py Outdated

#Create Proxy configuration file path
proxyConfigPath = os.path.join(path, "proxy.ini")
logger.debug('Proxy.ini PATH: ', proxyConfigPath)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woops, this is wrong. I need to use a + instead of comma to join the two items inside the logging.debug() code. Also, this is redundant and I should delete line 47

parser.add_argument('--unit', type=int, default=0, help='Specify Faraday unit to configure')

#Proxy options
parser.add_argument('--number', type=int, default=0, help='Set number of Faraday radios to use')
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may be dangerous and/or not work. Keep an eye on this one. Might need to default to 1?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually OK. Defaulting to 0 basically keeps the 1 in the proxy.ini file until you specify something other than 0 or 1 (since 0 is ignored... you'd never have 0 units to startup. Maybe in testmode but that's getting in the weeds for now). Programming a number.

This does allow negative numbers and any number that is positive

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK this is addressed in Issue #207

logger.info("Log initialization complete")


def saveProxyLog(name, config):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May not work without pip install creating ~user/.faraday/lib

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not applicable, folder created if not already existing whenever proxy is run:

https://github.com/FaradayRF/Faraday-Software/pull/203/files#diff-a9d2cba55827323291e9d0c49fd6f720R629

sys.exit(0)


def showProxyLogs():
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May not work without pip install creating ~user/.faraday/lib

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not applicable, folder created if not already existing whenever proxy is run:

https://github.com/FaradayRF/Faraday-Software/pull/203/files#diff-a9d2cba55827323291e9d0c49fd6f720R629

requirements.txt Outdated
@@ -1,4 +1,5 @@
appdirs==1.4.3
argparse==1.4.0
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't need this since python >2.6 has argparse in the stdlib

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also should possibly add setuptools?

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.
Copy link
Contributor

@kb1lqd kb1lqd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I sat down with Bryce and we went through all of the code updates. I verified that I could install, configure, and start proxy from the command line. I also verified that telemetry and and APRS also worked (also commanding local and remote) using traditional methods of manually running the github scripts.

kb1lqc added 2 commits June 18, 2017 18:47
It's part of stdlib in Python >2.6 so it's already there.
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.
@kb1lqc kb1lqc merged commit fcdadae into FaradayRF:master Jun 19, 2017
@kb1lqc
Copy link
Member Author

kb1lqc commented Jun 19, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants