-
Notifications
You must be signed in to change notification settings - Fork 3.1k
universal update script for linux/unix/osx #3965
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/usr/bin/python | ||
import os | ||
|
||
update_list = [] | ||
p = os.popen('sudo -H pip freeze --local',"r") | ||
while 1: | ||
line = p.readline() | ||
if not line: break | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can simplify these 3 lines to for line in p: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll do some work on making this universal for Windows also, I'm sure I could do OS checks and just split the nix and nt code as functions. I just added this in the fork to get some feedback as I wrote this a couple years back and decided hey why not actually introduce it to the community. I'll do some work on it and report back here and see what everyone thinks There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
update_list.append(line.rstrip('\n').split('=')[0]) | ||
counter = 0 | ||
while counter < len(update_list): | ||
os.system('sudo -H pip install -U "' + update_list[counter] + '"') | ||
counter += 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You don't use for entry in update_list:
subprocess.check_call(['sudo', '-H', 'pip', 'install', '-U', entry]) is probably simpler (and more secure, as you're not relying on shell quoting, and hence exposing yourself to security issues from weird package names). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a personal script, this is fine but you should probably use
subprocess.Popen
for production scripts.