Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed a few bugs and issues with variable naming - thanks martin and …

…pete for reviewing
  • Loading branch information...
commit 6d8eeb1cd01fc7106d5c8f7b3b5a7a2217384e60 1 parent cf1ec9d
@mlouro mlouro authored
Showing with 14 additions and 16 deletions.
  1. +14 −16 static_installer/management/commands/sid.py
View
30 static_installer/management/commands/sid.py
@@ -1,5 +1,6 @@
import os
import urllib2
+from urlparse import urlparse
from django.conf import settings
from django.core.management.base import BaseCommand, CommandError
@@ -24,10 +25,10 @@ def handle(self, *args, **options):
paths.append(dependency_path)
for path in paths:
- object = simplejson.loads(open(path, 'r').read())
+ json_obj = simplejson.loads(open(path, 'r').read())
- for item in object:
- install_dependencies(object.get(item, None), os.path.join(settings.STATIC_ROOT_DEFAULT, item))
+ for item in json_obj:
+ install_dependencies(json_obj.get(item, None), os.path.join(settings.STATIC_ROOT_DEFAULT, item))
@@ -35,26 +36,23 @@ def install_dependencies(dependencies, path):
for item in dependencies:
if type(dependencies).__name__ == 'dict':
- dir = os.path.join(path, item)
- if not os.path.exists(dir):
- print "mkdir %s.." % (dir)
- os.mkdir(dir)
+ folder = os.path.join(path, item)
+ if not os.path.exists(folder):
+ print "mkdir %s.." % (folder)
+ os.mkdir(folder)
install_dependencies(dependencies[item], os.path.join(path, item))
else:
- #remotefile = urllib2.urlopen(item)
-
- if item.find('#pack=') != -1:
- filename = item.split('#pack=')[-1]
+ parsed_url = urlparse(item)
+ if parsed_url[5] and parsed_url[5].find('filename=') != -1:
+ filename = parsed_url[5].replace('filename=', '')
else:
- filename = item.split('/')[-1].split('#')[0].split('?')[0]
+ filename = parsed_url[2].split('/')[-1]
print "downloading %s..." % item
- remote_file = urllib2.urlopen(item).read()
+ remote_file = urllib2.urlopen(item)
local_file = open(os.path.join(path, filename), 'w')
+ local_file.write(remote_file.read())
local_file.close()
-
- #print js
- #print css
Please sign in to comment.
Something went wrong with that request. Please try again.