Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix comma style; support zipfiles as well as tarballs

  • Loading branch information...
commit b6fab5dffa0e2ab083d45d4d0d1a01d4c8089f60 1 parent 2b86f4e
Joe Germuska authored
Showing with 20 additions and 14 deletions.
  1. +4 −4 cactus/cli.py
  2. +16 −10 cactus/site.py
8 cactus/cli.py
View
@@ -20,9 +20,9 @@
'''
def _init_parser():
parser = argparse.ArgumentParser(description=description)
- parser.add_argument('command',metavar="COMMAND", help="The command to execute (one of [create|build|serve|deploy] )")
- parser.add_argument('option1',metavar="OPTION1", nargs='?', help="option 1")
- parser.add_argument('option2',metavar="OPTION2", nargs='?', help="option 2")
+ parser.add_argument('command', metavar="COMMAND", help="The command to execute (one of [create|build|serve|deploy] )")
+ parser.add_argument('option1', metavar="OPTION1", nargs='?', help="option 1")
+ parser.add_argument('option2', metavar="OPTION2", nargs='?', help="option 2")
parser.add_argument('--skeleton', required=False, help="If provided, the path to a .tar.gz file or a directory which will be used in place of the default 'skeleton' for a cactus project.")
return parser
@@ -83,7 +83,7 @@ def main():
# Run the command
if command == 'create':
if not option1: exit('Missing path')
- create(option1,args)
+ create(option1, args)
elif command == 'build':
build(os.getcwd())
26 cactus/site.py
View
@@ -11,6 +11,7 @@
import socket
import tempfile
import tarfile
+import zipfile
import boto
@@ -64,12 +65,12 @@ def verify(self):
logging.info('This does not look like a (complete) cactus project (missing "%s" subfolder)', p)
sys.exit()
- def bootstrap(self,skeleton=None):
+ def bootstrap(self, skeleton=None):
"""
Bootstrap a new project at a given path.
"""
- skeleton_tarball = None
+ skeletonArchive = None
if skeleton is None:
from .skeleton import data
logging.info("Building from data")
@@ -77,22 +78,27 @@ def bootstrap(self,skeleton=None):
skeletonFile.write(base64.b64decode(data))
skeletonFile.close()
skeleton_tarball = skeletonFile.name
+ skeletonArchive = tarfile.open(name=skeleton_tarball, mode='r')
elif os.path.isfile(skeleton):
- if skeleton.endswith('.tar.gz') or skeleton.endswith('.tgz'):
- skeleton_tarball = skeleton
+ if tarfile.is_tarfile(skeleton):
+ skeletonArchive = tarfile.open(name=skeleton, mode='r')
+ elif zipfile.is_zipfile(skeleton):
+ skeletonArchive = zipfile.ZipFile(skeleton)
else:
- logging.error("At this time, skeleton argument must be a tarball or a directory (ending with .tar.gz or .tgz extension).")
+ logging.error("Unknown file archive type. At this time, skeleton argument must be a directory, a zipfile, or a tarball.")
sys.exit()
- if skeleton_tarball:
+ if skeletonArchive:
+ print skeletonArchive
os.mkdir(self.path)
- skeletonArchive = tarfile.open(name=skeleton_tarball, mode='r')
skeletonArchive.extractall(path=self.path)
skeletonArchive.close()
+ logging.info('New project generated at %s', self.path)
elif os.path.isdir(skeleton):
- shutil.copytree(skeleton,self.path)
-
- logging.info('New project generated at %s', self.path)
+ shutil.copytree(skeleton, self.path)
+ logging.info('New project generated at %s', self.path)
+ else:
+ logging.error("Cannot process skeleton '%s'. At this time, skeleton argument must be a directory, a zipfile, or a tarball." % skeleton)
def context(self):
"""
Please sign in to comment.
Something went wrong with that request. Please try again.