Beispiel #1
0
    def call(self, *args, **options):
        self._options = options
        self.base_path = 'base_path' in options and options['base_path'] or os.getcwd()

        if len(args) < 1:
            self.error("usage: duke startproject <project-name> [options]\n")

        if os.environ.get('DUKE_ENV') is not None:
            self.error("you cannot start a duke project from within a duke instance.\n")
       #else:
       #    django_project_name = prompt('Django project name:', validate=r'^[_a-zA-Z]\w*$',
       #            default=project_name.split('.')[0].replace('-','_'))

        project_name = args[0].replace('/', '')

        if len(args) > 1 and args[1] == '.':
            project_path = self.base_path
        else:
            project_path = os.path.join(self.base_path, project_name)

            if os.path.exists(project_path):
                self.error("Could not create project \"%s\", directory already exists." % project_name)
            else:
                os.makedirs(project_path)

        create_from_template('setup.py', project_path, {
            'project_name': project_name,
            'duke_client_version': dukeclient.VERSION,
        })

        self.info("Created project %s" % project_name)
Beispiel #2
0
 def install_file(self, filename, path, context=False, quiet=False, overwrite=False):
     if os.path.exists(os.path.join(path, filename)) and overwrite is False:
         if quiet is False:
             self.info("A %s has been found, will be using it." % filename)
         return False
     else:
         if quiet is False:
             self.info("Installing %s" % filename)
         create_from_template(filename, path, context)
         return True
Beispiel #3
0
 def make(x,path):
     if x[0] == EMPTY:
         self.local('touch %s' % os.path.join(path, x[1].replace('<app-name>',project_name)))
     elif x[0] == TEMPLATE:
         create_from_template(os.path.join('startapp',x[1]), path, variables={
             'project_name': project_name,
             'duke_client_version': dukeclient.VERSION,
         },dest_name=x[1].replace("<app-name>",project_name))
     elif x[0] == DIR:
         os.makedirs(os.path.join(path,x[1].replace("<app-name>",project_name)))
     elif x[0] == BINARY:
         create_from_template(os.path.join('startapp',x[1]), path,dest_name=x[1].replace("<app-name>",project_name))
         pass
Beispiel #4
0
 def install_file(self,
                  filename,
                  path,
                  context=False,
                  quiet=False,
                  overwrite=False):
     if os.path.exists(os.path.join(path, filename)) and overwrite is False:
         if quiet is False:
             self.info("A %s has been found, will be using it." % filename)
         return False
     else:
         if quiet is False:
             self.info("Installing %s" % filename)
         create_from_template(filename, path, context)
         return True
Beispiel #5
0
 def make(x, path):
     if x[0] == EMPTY:
         self.local('touch %s' % os.path.join(
             path, x[1].replace('<app-name>', project_name)))
     elif x[0] == TEMPLATE:
         create_from_template(os.path.join('startapp', x[1]),
                              path,
                              variables={
                                  'project_name': project_name,
                                  'duke_client_version':
                                  dukeclient.VERSION,
                              },
                              dest_name=x[1].replace(
                                  "<app-name>", project_name))
     elif x[0] == DIR:
         os.makedirs(
             os.path.join(path, x[1].replace("<app-name>",
                                             project_name)))
     elif x[0] == BINARY:
         create_from_template(os.path.join('startapp', x[1]),
                              path,
                              dest_name=x[1].replace(
                                  "<app-name>", project_name))
         pass