def main(self): console('Generating new Application Framework project ...') dirpath = self.options.dir while not dirpath: default = os.path.join(os.getcwd(), 'appfwk_project') dirpath = prompt('\nEnter path for project files', default=default) dirpath = os.path.abspath(dirpath) if os.path.exists(dirpath): console('Project directory already exists, aborting.') return self.create_project_directory(dirpath) self.create_local_settings(dirpath) self.collectreports(dirpath) if self.options.offline_js: self.get_offline_js(dirpath) if not self.options.no_git: self.initialize_git(dirpath) if not self.options.no_init: self.initialize_project(dirpath) console('\n*****\n') console('App Framework project created.') if self.options.no_init: console("Change to that directory and run " "'steel appfwk init' to initialize the project.")
def main(self): console('Generating new SteelScript workspace...') dirpath = self.options.dir while not dirpath: default = os.path.join(os.getcwd(), 'steelscript-workspace') dirpath = prompt('\nEnter path for workspace files', default=default) dirpath = os.path.abspath(dirpath) if os.path.exists(dirpath): console('Workspace directory already exists, aborting.') return self.create_workspace_directory(dirpath) self.collect_examples(dirpath, True) if self.options.git: self.initialize_git(dirpath) console('\n*****\n') console('SteelScript workspace created.')
def main(self): options = self.options interactive = not options.non_interactive if options.wave: if options.name and options.name != 'wave': self.parser.error("Name may not be specified for the sample " "WaveGenerator plugin") sys.exit(1) options.name = 'wave' options.title = 'Sample WaveGenerator' options.description = 'Generate sine and cosine waves' options.author = 'Riverbed' options.author_email = '*****@*****.**' else: # Ask questions if options.name: if not re.match('^[a-z0-9_]+$', options.name): self.parser.error('Invalid name: please use only ' 'lowercase letters, numbers, and ' 'underscores.\n') else: done = False while not done: options.name = prompt( 'Give a simple name for your plugin (a-z, 0-9, _)') if not re.match('^[a-z0-9_]+$', options.name): self.parser.error('Invalid name: please use only ' 'lowercase letters, numbers, and ' 'underscores.\n') else: done = True if not options.title and interactive: options.title = prompt('Give your plugin a title', default='') if not options.description and interactive: options.description = prompt('Briefly describe your plugin', default='') if not options.author and interactive: options.author = prompt("Author's name", default='') if not options.author_email and interactive: options.author_email = prompt("Author's email", default='') options.Name = options.name[0:1].upper() + options.name[1:] if not options.title: options.title = options.name which = 'wave' if options.wave else '__plugin__' basedir = os.path.join( os.path.dirname(steelscript.appfwk.commands.__file__), 'data', 'steelscript-' + which) targetbasedir = os.path.join(os.path.abspath(options.dir), 'steelscript-' + options.name) for (dir, subdirs, files) in os.walk(basedir): targetdir = dir.replace(basedir, targetbasedir) targetdir = targetdir.replace(which, options.name) if dir == basedir: if os.path.exists(targetdir): self.parser.error(('Target directory already exists: ' '{0}').format(targetdir)) os.mkdir(targetdir.format(which=options.name)) for f in files: if (f.endswith('~') or f.endswith('.pyc') or f.endswith('#')): continue srcfile = os.path.join(dir, f) dstfile = os.path.join( targetdir, (f.replace('.py.in', '.py').replace(which, options.name))) process_file(srcfile, dstfile, vars(options)) print('Writing: {dst}'.format(dst=dstfile)) shell('(cd {dir}; python setup.py develop )'.format(dir=targetbasedir)) write_relver = True if not self.options.nogit: if self.initialize_git(targetbasedir): write_relver = False if write_relver: relver = open(os.path.join(targetbasedir, 'RELEASE-VERSION'), 'w') relver.write('0.0.1') relver.close()
def main(self): options = self.options interactive = not options.non_interactive if options.wave: if options.name and options.name != 'wave': self.parser.error("Name may not be specified for the sample " "WaveGenerator plugin") sys.exit(1) options.name = 'wave' options.title = 'Sample WaveGenerator' options.description = 'Generate sine and cosine waves' options.author = 'Riverbed' options.author_email = '*****@*****.**' else: # Ask questions if options.name: if not re.match('^[a-z0-9_]+$', options.name): self.parser.error('Invalid name: please use only ' 'lowercase letters, numbers, and ' 'underscores.\n') else: done = False while not done: options.name = prompt( 'Give a simple name for your plugin (a-z, 0-9, _)') if not re.match('^[a-z0-9_]+$', options.name): self.parser.error('Invalid name: please use only ' 'lowercase letters, numbers, and ' 'underscores.\n') else: done = True if not options.title and interactive: options.title = prompt('Give your plugin a title', default='') if not options.description and interactive: options.description = prompt('Briefly describe your plugin', default='') if not options.author and interactive: options.author = prompt("Author's name", default='') if not options.author_email and interactive: options.author_email = prompt("Author's email", default='') options.Name = options.name[0:1].upper() + options.name[1:] if not options.title: options.title = options.name which = 'wave' if options.wave else '__plugin__' basedir = os.path.join( os.path.dirname(steelscript.appfwk.commands.__file__), 'data', 'steelscript-' + which) targetbasedir = os.path.join(os.path.abspath(options.dir), 'steelscript-' + options.name) for (dir, subdirs, files) in os.walk(basedir): targetdir = dir.replace(basedir, targetbasedir) targetdir = targetdir.replace(which, options.name) if dir == basedir: if os.path.exists(targetdir): self.parser.error(('Target directory already exists: ' '{0}').format(targetdir)) os.mkdir(targetdir.format(which=options.name)) for f in files: if ( f.endswith('~') or f.endswith('.pyc') or f.endswith('#')): continue srcfile = os.path.join(dir, f) dstfile = os.path.join(targetdir, (f.replace('.py.in', '.py') .replace(which, options.name))) process_file(srcfile, dstfile, vars(options)) print('Writing: {dst}'.format(dst=dstfile)) shell('(cd {dir}; python setup.py develop )'.format(dir=targetbasedir)) write_relver = True if not self.options.nogit: if self.initialize_git(targetbasedir): write_relver = False if write_relver: relver = open(os.path.join(targetbasedir, 'RELEASE-VERSION'), 'w') relver.write('0.0.1') relver.close()