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

Fixed pathing for OSes (GPG, TMP, Home, etc. for Windows/Linux/Unix) #104

Closed
wants to merge 22 commits into from

Conversation

F9Alejandro
Copy link

Updated single commit to better track/organize for pulling.

libpius/path.py handles pathing of the local machine and determines what to use or do based on the host OS.

set_tmpdir() is hard coded for Mac (Darwin) and linux as $TMPDIR doesn't respond correctly or is not an env variable in varying versions.

(Note: MacOS uses mktemp which is not able to be accessed by anyone* except the user, some versions of linux use $TMP/$TEMP/$TMPDIR/$TEMPDIR or just doesn't exist at all)
*includes root

jaymzh and others added 3 commits May 17, 2018 08:57
* Dropping cached passphrased
* Dropping interactive mode
* Dropping gpg1 support
libpius/path.py Outdated Show resolved Hide resolved
libpius/path.py Outdated Show resolved Hide resolved
libpius/path.py Outdated Show resolved Hide resolved
@F9Alejandro
Copy link
Author

Changes made has been tested on Mac, Linux, and Windows. pius.spec needs to have cross compatibility for other OSes, or multi stage depending on the platform run a different set of instructions.

Copy link
Owner

@jaymzh jaymzh left a comment

Choose a reason for hiding this comment

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

Thanks for putting effort into the Windows stuff... definitely not something I have done. :) Appreciated.

libpius/path.py Show resolved Hide resolved
libpius/path.py Outdated Show resolved Hide resolved
libpius/path.py Show resolved Hide resolved
libpius/path.py Outdated Show resolved Hide resolved
libpius/path.py Outdated Show resolved Hide resolved
libpius/path.py Outdated Show resolved Hide resolved
pius-keyring-mgr Outdated Show resolved Hide resolved
pius-keyring-mgr Outdated Show resolved Hide resolved
Fixed capitals for non constants. and made variable names more clear for others.
added default linux tempdir path as constant
Decided on Constant being in the path file.
Decided against having tempdir path being in this file.
updated function names and added import for some constants, also provided a check to see if the platform is windows or linux, if windows then do a normal which search, if linux then use the path constant with normal path separators to see if it exists with the other bin files.
fixed function names to reflect the changes in the paths file
due to calling path in constants.py LINUX_TEMPDIR and BIN_PATHS need to be in this file as it will cause a import loop between this file and constants.py
Fixed variable name not being complete, and changed hard code of existing hard code constant.
fixed function names to reflect previous changes
fixed oversight. %APPDATA% places user in their roaming folder, no need to have it as part of path join as it is already in the home variable.
Removed unused import
libpius/path.py Outdated Show resolved Hide resolved
libpius/path.py Outdated Show resolved Hide resolved
libpius/path.py Show resolved Hide resolved
libpius/path.py Outdated Show resolved Hide resolved
@jaymzh
Copy link
Owner

jaymzh commented Sep 21, 2018

I see I hadn't been very clear on some of my comments before - my apologies. Please don't hesitate to ask for further clarification on anything else. Thanks again for improving the experience for non-Linux users!

removed old comment from EOF.
removed elif statement from incorrect spot.
added back a previously deleted function.
added 2 checks to pius home on linux/unix systems.
@F9Alejandro
Copy link
Author

F9Alejandro commented Sep 23, 2018 via email

Seperated MacOS and Linux binary paths
Mac check joins mac and linux binary paths
@F9Alejandro
Copy link
Author

Latest commit should fix the last of your major concerns, push come to shove i could make it more narrowed down to just Cellar (Homebrew) and MacGPG2 (GPG Tools suite)

libpius/path.py Outdated Show resolved Hide resolved
libpius/path.py Outdated Show resolved Hide resolved
libpius/path.py Outdated Show resolved Hide resolved
libpius/path.py Outdated Show resolved Hide resolved
libpius/path.py Outdated Show resolved Hide resolved
libpius/path.py Outdated Show resolved Hide resolved
Additional fixes to issues that have not been caught previously.
libpius/path.py Outdated Show resolved Hide resolved
Change ; to :
Fixed ordering of files to be checked for.
New function to find current piusrc
fixed some typos in nested if statement.
added new function to get piusrc and check if the home for pius is a directory or a file.
@F9Alejandro
Copy link
Author

Resolved the issue about order of pius home checks in turn also fixing a hard coded path that should be checked if it is a dir or not.

gpg = which('gpg2')
elif sys.platform == "darwin":
#joining all possible paths for location of mac binaries
BIN_PATHS = MAC_BIN_PATHS+":"+LINUX_BIN_PATHS)
Copy link
Owner

Choose a reason for hiding this comment

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

trailing ) here...

if os.path.exists(os.path.join(usrhome, '.pius')) and os.access(os.path.join(usrhome,'.pius'), mode) and os.path.isdir(os.path.join(usrhome,'.pius')):
piushome = os.path.join(usrhome,'.pius')
elif os.path.exists(os.path.join(usrhome, '.piusrc')) and os.access(os.path.join(usrhome,'.piusrc'), mode) and os.path.isdir(os.path.join(usrhome,'.piusrc')):
piushome = os.path.join(usrhome,'.piusrc')
Copy link
Owner

Choose a reason for hiding this comment

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

.piusrc was never a dir, it was always a file.

#fall back if above is not applicable
else:
piushome = os.path.join(usrhome, '.pius')
return piushome
Copy link
Owner

Choose a reason for hiding this comment

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

this method returns a dir in the if, a file in the first elif, a dir in the second, a dir in the third. and a file in the else


def get_piusrc(path):
if sys.platform == "win32":
if os.path.islink(path) and not os.path.isfile(path):
Copy link
Owner

Choose a reason for hiding this comment

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

should this be and os.path.isdir(path)?

if sys.platform == "win32":
if os.path.islink(path) and not os.path.isfile(path):
return os.path.join(path, 'piusrc')
elif os.path.isfile(path) and not os.path.islink(path):
Copy link
Owner

Choose a reason for hiding this comment

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

if it's not a file and not a link, then... it's a ... file?


def get_tmpdir(dir):
if sys.platform == "win32":
tempdir = os.environ.get('TEMP')
Copy link
Owner

Choose a reason for hiding this comment

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

what if that's not defined?

if os.environ.get('USER') == "root":
tempdir = '/private/tmp/'
else:
tempdir = os.environ.get('TMPDIR')
Copy link
Owner

Choose a reason for hiding this comment

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

same

@jaymzh jaymzh added the waitingonsubmitter Waiting on the sbumitter label Jun 28, 2019
@jaymzh jaymzh closed this Jul 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waitingonsubmitter Waiting on the sbumitter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants