Skip to content

Commit

Permalink
- use python built in methods
Browse files Browse the repository at this point in the history
- eliminate the usage of wget for manual install for systems that doesn't have wget preinstalled.
- works with Python 2 and 3
  • Loading branch information
faraco committed Oct 21, 2017
1 parent 7537228 commit cd07736
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions download-xflux.py
@@ -1,5 +1,11 @@
from sys import maxsize
import os
from sys import maxsize, version_info

if version_info[0] == 3:
from urllib.request import urlretrieve
else:
from urllib import urlretrieve

import tarfile

# There is similar code in ./debian/postinst. If you are changing this
# you probably want to change that too.
Expand All @@ -12,8 +18,17 @@ def download_xflux():
print("Downloading 64-bit xflux ...")
url = "https://justgetflux.com/linux/xflux64.tgz"
tarchive = "/tmp/xflux.tgz"
os.system("wget '%s' -O'%s'" % (url, tarchive))
os.system("tar -xvf '%s'" % tarchive)

# use python's builtins methods to eliminate external program
# dependencies for manual install
# in case internet connection isn't available to download wget
# & not every linux system (minimal) has wget (nor curl) preinstalled.
urlretrieve(url, tarchive)

print("Extracting {} ...".format(tarchive))
tar = tarfile.open(tarchive)
tar.extractall()
tar.close()

if __name__ == '__main__':
download_xflux()

0 comments on commit cd07736

Please sign in to comment.