fix issues of downloading using manifest
diff --git a/xos/synchronizers/onboarding/xosbuilder.py b/xos/synchronizers/onboarding/xosbuilder.py
index 9e3c2bb..4236f74 100644
--- a/xos/synchronizers/onboarding/xosbuilder.py
+++ b/xos/synchronizers/onboarding/xosbuilder.py
@@ -47,13 +47,14 @@
         manifest = []
         manifest_lines = file(fn).readlines()
         manifest_lines = [x.strip() for x in manifest_lines]
-        manifest_lines = [x for x in manifest.lines if x]
+        manifest_lines = [x for x in manifest_lines if x]
         for line in manifest_lines:
-            url_parts = urlsplit(scr.full_url)
-            url_parts.path = os.path.join(os.path.join(*os.path.split(url_parts).path[:-1]),line)
-            url = urlparse.urlunsplit(url_parts)
+            url_parts = urlparse.urlsplit(scr.full_url)
+            new_path = os.path.join(os.path.join(*os.path.split(url_parts.path)[:-1]),line)
+            url = urlparse.urlunsplit( (url_parts.scheme, url_parts.netloc, new_path, url_parts.query, url_parts.fragment) )
 
             build_fn = os.path.join(self.get_dest_dir(scr), line)
+            download_fn = os.path.join(self.build_dir, build_fn)
 
             manifest.append( (url, download_fn, build_fn) )
         return manifest
@@ -65,11 +66,15 @@
         obj = urllib2.urlopen(url)
         file(dest_fn,"w").write(obj.read())
 
+        # make python files executable
+        if dest_fn.endswith(".py"): # and contents.startswith("#!"):
+            os.chmod(dest_fn, 0755)
+
     def download_resource(self, scr):
         if scr.format == "manifest":
             manifest_fn = self.get_download_fn(scr)
             self.download_file(scr.full_url, manifest_fn)
-            mainfest = self.read_manifest(scr, manifest_fn)
+            manifest = self.read_manifest(scr, manifest_fn)
             for (url, download_fn, build_fn) in manifest:
                 self.download_file(url, download_fn)
         else:
@@ -137,7 +142,7 @@
         dockerfile_fn = "Dockerfile.%s" % controller.name
         dockerfile = ["FROM %s" % self.source_sync_image]
         dockerfile = dockerfile + lines
-        file(os.path.join(self.build_dir, dockerfile_fn), "w").writelines(dockerfile)
+        file(os.path.join(self.build_dir, dockerfile_fn), "w").write("\n".join(dockerfile)+"\n")
 
         return {"dockerfile_fn": dockerfile_fn,
                 "docker_image_name": "xosproject/xos-synchronizer-%s" % controller.name}