Пример #1
0
 def preloop(self, *args, **kwargs):
     """..."""
     webapp_path=os.path.join(self.projpath, "webapp")
     if not os.path.exists(webapp_path):
         self.info("Your application doesn't have 'webapp' folder. Copying necessary files...")
         import pyfrid.management.templates.project_template.webapp as project_webapp
         copytree(project_webapp.__path__[0], os.path.join(self.projpath,"webapp"))
     import zipfile
     static_path=os.path.join(webapp_path, "static")
     for f in os.listdir(static_path):
         if f.endswith('.zip'):
             mz=zipfile.ZipFile(os.path.join(static_path, f))
             mz.extractall(static_path)
     return True
Пример #2
0
    name='newproj'
    
    descr = "Creates a project directory structure for the given project name in the current directory"
    args = "project_name"
    option_list=[]
        
    def handle(self, *args, **options):
        proj_name=''
        if not args:
            try:
                while not proj_name:
                    proj_name=raw_input("Type name of the project: ")
            except EOFError, err:
                raise CommandError(str(err))
        else:
            proj_name=args[0]
        import re
        import shutil
        if not re.search(r'^[_a-zA-Z]\w*$', proj_name):
            raise CommandError("{0} is not a valid project name. Please use only numbers, letters and underscores".format(proj_name))
        directory = os.getcwd()
        dst_dir = os.path.join(directory, proj_name)
        if os.path.exists(dst_dir):
            raise CommandError("Directory '{0}' already exists".format(dst_dir))
        for pyfrid_path in pyfrid.__path__:
            src_dir = os.path.join(pyfrid_path, "management",'templates', 'project_template')
            if os.path.exists(src_dir):
                copytree(src_dir,dst_dir)
        return "Project '{0}' was successfully created".format(proj_name)