Permalink
Browse files

Make downloader work properly

  • Loading branch information...
nwgh committed May 1, 2012
1 parent c0ce811 commit bd7848cbff49b558567119480c9bbb87ceabeb12
Showing with 12 additions and 10 deletions.
  1. +5 −4 stoneridge.py
  2. +7 −6 stoneridge_downloader.py
View
@@ -5,6 +5,7 @@
import argparse
import ConfigParser
import inspect
+import os
import platform
import StringIO
import subprocess
@@ -115,7 +116,7 @@ def get_xpcshell_bin():
return 'xpcshell.exe'
return 'xpcshell'
-def _determine_os_name(self):
+def _determine_os_name():
"""Determine the os from platform.system
"""
global os_name
@@ -128,9 +129,9 @@ def _determine_os_version():
"""
global os_version
if os_name == 'linux':
- os_version = ' '.join(platform.linux_distribution[0:2])
+ os_version = ' '.join(platform.linux_distribution()[0:2])
elif os_name == 'mac':
- os_version = platform.mac_ver[0]
+ os_version = platform.mac_ver()[0]
elif os_name == 'windows':
os_version = platform.win32_ver()[1]
else:
@@ -215,7 +216,7 @@ def __init__(self, **kwargs):
self.add_argument('--workdir', dest='_sr_work_', required=True,
help='Directory to do all the work in')
- def parse_args(self, **kwargss):
+ def parse_args(self, **kwargs):
args = argparse.ArgumentParser.parse_args(self, **kwargs)
setup_dirnames(args._sr_root_, args._sr_work_)
View
@@ -20,17 +20,18 @@ def _download_file(self, filename):
url = 'http://%s/%s/%s/%s' % (self.server, self.downloaddir,
stoneridge.download_platform, filename)
r = requests.get(url)
+ if r.status_code != 200:
+ raise Exception, 'Error downloading %s: %s' % (filename,
+ r.status_code)
with file(filename, 'wb') as f:
f.write(r.content)
def run(self):
- os.chdir(stoneridge.workdir)
+ if not os.path.exists(stoneridge.downloaddir):
+ os.mkdir(stoneridge.downloaddir)
+ os.chdir(stoneridge.downloaddir)
- filename = os.path.join(stoneridge.downloaddir,
- 'firefox.%s' % (stoneridge.download_suffix),))
- self._download_file(filename)
-
- filename = os.path.join(stoneridge.downloaddir, 'tests.zip')
+ self._download_file('firefox.%s' % (stoneridge.download_suffix,))
self._download_file('tests.zip')

0 comments on commit bd7848c

Please sign in to comment.