Skip to content

Instantly share code, notes, and snippets.

@mmurdoch
Created November 6, 2012 18:18
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmurdoch/4026516 to your computer and use it in GitHub Desktop.
Save mmurdoch/4026516 to your computer and use it in GitHub Desktop.
Get dateutil
import os
import urllib2
import tarfile
import shutil
workingPath = os.getcwd()
tempPath = os.path.join(workingPath, 'temp')
dateutilArchiveDir = 'python-dateutil-1.5'
dateutilArchive = dateutilArchiveDir + '.tar.gz'
dateutilArchivePath = os.path.join(tempPath, dateutilArchive)
try:
os.mkdir(tempPath)
except OSError:
pass
dateutilArchiveUrl = urllib2.urlopen('http://labix.org/download/python-dateutil/' + dateutilArchive)
localArchive = open(dateutilArchivePath, 'w')
localArchive.write(dateutilArchiveUrl.read())
localArchive.close()
dateutilArchiveUrl.close()
archive = tarfile.open(dateutilArchivePath, 'r:gz')
try:
os.chdir(tempPath)
archive.extractall()
finally:
archive.close()
os.chdir(workingPath)
dateutilDir = 'dateutil'
tempDateutilPath = os.path.join(os.path.join(tempPath, dateutilArchiveDir), dateutilDir)
dateutilPath = os.path.join(workingPath, dateutilDir)
shutil.rmtree(dateutilPath, True)
shutil.copytree(tempDateutilPath, dateutilPath)
shutil.rmtree(tempPath)
@mmurdoch
Copy link
Author

mmurdoch commented Nov 6, 2012

Fetches dateutil into Pythonista.

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