rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
self.assertEqual(viewlet.locked_icon(), "") self.login('Alan') viewlet = DocumentBylineViewlet(context, request, None, None) viewlet.update()
def test_locked_icon(self): request = self.app.REQUEST self.setRoles(['Manager', 'Member']) self.portal.invokeFactory('Document', 'd1') context = getattr(self.portal, 'd1') viewlet = DocumentBylineViewlet(context, request, None, None) viewlet.update() self.assertEqual(viewlet.locked_icon(), "") ILockable(context).lock(...
self.search_input_id = "nonlivesearchGadget"
self.search_input_id = "nolivesearchGadget"
def update(self): super(SearchBoxViewlet, self).update()
path = self.obj.getIcon(1)
def url(self): portal_url = getToolByName(self.context, 'portal_url')() path = self.obj.getIcon(1) return "%s/%s" % (portal_url, path)
if path.startswith(action_path):
if path.startswith(action_path + '/'):
def selectedTabs(self, default_tab='index_html', portal_tabs=()): plone_url = getToolByName(self.context, 'portal_url')() plone_url_len = len(plone_url) request = self.request valid_actions = []
print kern_api
def printbuild(build,seperator): print '%10s%c' % (build,seperator),
layer = Layer([tcl_ptc.ptc_layer])
layer = Layer([common.common_layer])
def afterSetUp(self): fiveconfigure.debug_mode = True zcml.load_config('testing.zcml', package=formcriteria) fiveconfigure.debug_mode = False
(key+'-column', value) for key, value in aq_parent(aq_parent(self)).listMetaDataFields().items()+( ('getPath', 'URL'),))
(key+'-column', fields.getValue(key)) for key in fields)
def listMetaDataVocab(self): """Append '-column' suffix to avoid id clashes""" return atapi.DisplayList( (key+'-column', value) for key, value in aq_parent(aq_parent(self)).listMetaDataFields().items()+( ('getPath', 'URL'),))
_open_re = re.compile(r'.*open\("([^"]*)", ([^,)]*)') _stat64_re = re.compile(r'.*stat64\("([^"]*)", .*') _execve_re = re.compile(r'.*execve\("([^"]*)", .*') _mkdir_re = re.compile(r'.*mkdir\("([^"]*)", .*') _rename_re = re.compile(r'.*rename\("[^"]*", "([^"]*)"\)') _kill_re = re.compile(r'.*killed by.*') _chdir_re = r...
_open_re = re.compile(r'(?P<pid>\d+)\s+open\("(?P<name>[^"]*)", (?P<mode>[^,)]*)') _stat64_re = re.compile(r'(?P<pid>\d+)\s+stat64\("(?P<name>[^"]*)", .*') _execve_re = re.compile(r'(?P<pid>\d+)\s+execve\("(?P<name>[^"]*)", .*') _mkdir_re = re.compile(r'(?P<pid>\d+)\s+mkdir\("(?P<name>[^"]*)", .*') _...
def has_strace(): """ Return True if this system has strace. """ if platform.system() == 'Windows': # even if windows has strace, it's probably a dodgy cygwin one return False try: subprocess.Popen('strace', stderr=subprocess.PIPE) return True except OSError: return False
shell('strace', '-fo', outname, '-e', 'trace=open,stat64,execve,exit_group,chdir,mkdir,rename',
shell('strace', '-fo', outname, '-e', 'trace=open,stat64,execve,exit_group,chdir,mkdir,rename,clone,vfork,fork',
def _do_strace(self, args, outfile, outname): """ Run strace on given command args, sending output to file. Return (status code, list of dependencies, list of outputs). """ shell('strace', '-fo', outname, '-e', 'trace=open,stat64,execve,exit_group,chdir,mkdir,rename', args, silent=False)
cwds = [] cwd = '.'
cwd = '.'
def _do_strace(self, args, outfile, outname): """ Run strace on given command args, sending output to file. Return (status code, list of dependencies, list of outputs). """ shell('strace', '-fo', outname, '-e', 'trace=open,stat64,execve,exit_group,chdir,mkdir,rename', args, silent=False)
deps = set() outputs = set()
processes = {} unfinished = {}
def _do_strace(self, args, outfile, outname): """ Run strace on given command args, sending output to file. Return (status code, list of dependencies, list of outputs). """ shell('strace', '-fo', outname, '-e', 'trace=open,stat64,execve,exit_group,chdir,mkdir,rename', args, silent=False)
if open_match:
if execve_match: pid = execve_match.group('pid') if pid not in processes: processes[pid] = StraceProcess() match = execve_match elif clone_match: pid = clone_match.group('pid') pid_clone = clone_match.group('pid_clone') processes[pid] = StraceProcess(processes[pid_clone].cwd) elif open_match:
def _do_strace(self, args, outfile, outname): """ Run strace on given command args, sending output to file. Return (status code, list of dependencies, list of outputs). """ shell('strace', '-fo', outname, '-e', 'trace=open,stat64,execve,exit_group,chdir,mkdir,rename', args, silent=False)
mode = match.group(2)
mode = match.group('mode')
def _do_strace(self, args, outfile, outname): """ Run strace on given command args, sending output to file. Return (status code, list of dependencies, list of outputs). """ shell('strace', '-fo', outname, '-e', 'trace=open,stat64,execve,exit_group,chdir,mkdir,rename', args, silent=False)
elif execve_match: cwds.append(cwd) match = execve_match
def _do_strace(self, args, outfile, outname): """ Run strace on given command args, sending output to file. Return (status code, list of dependencies, list of outputs). """ shell('strace', '-fo', outname, '-e', 'trace=open,stat64,execve,exit_group,chdir,mkdir,rename', args, silent=False)
name = match.group(1)
name = match.group('name') pid = match.group('pid') cwd = processes[pid].cwd
def _do_strace(self, args, outfile, outname): """ Run strace on given command args, sending output to file. Return (status code, list of dependencies, list of outputs). """ shell('strace', '-fo', outname, '-e', 'trace=open,stat64,execve,exit_group,chdir,mkdir,rename', args, silent=False)
if self._builder._is_relevant(name) \ and (os.path.isfile(name) or os.path.isdir(name) or not os.path.lexists(name)): if not self.ignore(name): if is_output: outputs.add(name) else: deps.add(name)
if (self._builder._is_relevant(name) and not self.ignore(name) and (os.path.isfile(name) or os.path.isdir(name) or not os.path.lexists(name))): if is_output: processes[pid].add_output(name) else: processes[pid].add_dep(name)
def _do_strace(self, args, outfile, outname): """ Run strace on given command args, sending output to file. Return (status code, list of dependencies, list of outputs). """ shell('strace', '-fo', outname, '-e', 'trace=open,stat64,execve,exit_group,chdir,mkdir,rename', args, silent=False)
cwd = os.path.join(cwd, match.group(1))
processes[pid].cwd = os.path.join(processes[pid].cwd, match.group('cwd'))
def _do_strace(self, args, outfile, outname): """ Run strace on given command args, sending output to file. Return (status code, list of dependencies, list of outputs). """ shell('strace', '-fo', outname, '-e', 'trace=open,stat64,execve,exit_group,chdir,mkdir,rename', args, silent=False)
cwd = cwds.pop() status = int(match.group(1))
status = int(match.group('status')) deps = set() outputs = set() for pid, process in processes.items(): deps = deps.union(process.deps) outputs = outputs.union(process.outputs)
def _do_strace(self, args, outfile, outname): """ Run strace on given command args, sending output to file. Return (status code, list of dependencies, list of outputs). """ shell('strace', '-fo', outname, '-e', 'trace=open,stat64,execve,exit_group,chdir,mkdir,rename', args, silent=False)
handle, outname = tempfile.mkstemp()
if self.keep_temps: outname = 'strace%03d.txt' % self.temp_count self.temp_count += 1 handle = os.open(outname, os.O_CREAT) else: handle, outname = tempfile.mkstemp()
def __call__(self, *args): """ Run command and return its dependencies and outputs, using strace to determine dependencies (by looking at what files are opened or modified). """ handle, outname = tempfile.mkstemp() try: try: outfile = os.fdopen(handle, 'r') except: os.close(handle) raise try: status, deps, outputs = se...
os.remove(outname)
if self.keep_temps: os.remove(outname)
def __call__(self, *args): """ Run command and return its dependencies and outputs, using strace to determine dependencies (by looking at what files are opened or modified). """ handle, outname = tempfile.mkstemp() try: try: outfile = os.fdopen(handle, 'r') except: os.close(handle) raise try: status, deps, outputs = se...
try: self._builder.runner = StraceRunner(self._builder) except RunnerUnsupportedException:
if self._runner is None:
def __call__(self, *args): """ Smart command runner that replaces itself in self._builder.runner the first time it is used. It uses StraceRunner if it can, otherwise AtimesRunner if available, otherwise AlwaysRunner. """
self._builder.runner = AtimesRunner(self._builder)
self._runner = StraceRunner(self._builder)
def __call__(self, *args): """ Smart command runner that replaces itself in self._builder.runner the first time it is used. It uses StraceRunner if it can, otherwise AtimesRunner if available, otherwise AlwaysRunner. """
self._builder.runner = AlwaysRunner(self._builder) return self._builder.runner(*args)
try: self._runner = AtimesRunner(self._builder) except RunnerUnsupportedException: self._runner = AlwaysRunner(self._builder) return self._runner(*args)
def __call__(self, *args): """ Smart command runner that replaces itself in self._builder.runner the first time it is used. It uses StraceRunner if it can, otherwise AtimesRunner if available, otherwise AlwaysRunner. """
"""Set the runner for this builder. "runner" is either a callable compatible with the Runner class, or a string selecting one of the
"""Set the runner for this builder. "runner" is either a Runner subclass (e.g. SmartRunner), or a string selecting one of the
def set_runner(self, runner): """Set the runner for this builder. "runner" is either a callable compatible with the Runner class, or a string selecting one of the standard runners ("atimes_runner", "strace_runner", "always_runner", or "smart_runner").""" try: self.runner = self._runner_map[runner](self) except KeyErro...
if not self._builder.ignore.search(name):
if not self.ignore(name):
def __call__(self, *args): """ Run command and return its dependencies and outputs, using before and after access times to determine dependencies. """
outputs.append(name)
if not self.ignore(name): outputs.append(name)
def __call__(self, *args): """ Run command and return its dependencies and outputs, using before and after access times to determine dependencies. """
if is_output: outputs.add(name) else: if not self._builder.ignore.search(name):
if not self.ignore(name): if is_output: outputs.add(name) else:
def _do_strace(self, args, outfile, outname): """ Run strace on given command args, sending output to file. Return (status code, list of dependencies, list of outputs). """ shell('strace', '-fo', outname, '-e', 'trace=open,stat64,execve,exit_group,chdir,mkdir,rename', args, silent=False)
if self.keep_temps:
if not self.keep_temps:
def __call__(self, *args): """ Run command and return its dependencies and outputs, using strace to determine dependencies (by looking at what files are opened or modified). """ if self.keep_temps: outname = 'strace%03d.txt' % self.temp_count self.temp_count += 1 handle = os.open(outname, os.O_CREAT) else: handle, outn...
parser.add_option('-k', '--keep', action='store_false',
parser.add_option('-k', '--keep', action='store_true',
def parse_options(usage, extra_options=None): """ Parse command line options and return (parser, options, args). """ parser = optparse.OptionParser(usage='Usage: %prog '+usage, version='%prog '+__version__) parser.disable_interspersed_args() parser.add_option('-t', '--time', action='store_true', help='use file modifica...
if not StraceRunner.has_strace():
self.strace_version = StraceRunner.get_strace_version() if self.strace_version == 0:
def __init__(self, builder): if not StraceRunner.has_strace(): raise RunnerUnsupportedException('strace is not available') self._builder = builder self.temp_count = 0
def has_strace(): """ Return True if this system has strace. """
def get_strace_version(): """ Return 0 if this system doesn't have strace, nonzero otherwise (64 if strace supports stat64, 32 otherwise). """
def has_strace(): """ Return True if this system has strace. """ if platform.system() == 'Windows': # even if windows has strace, it's probably a dodgy cygwin one return False try: subprocess.Popen('strace', stderr=subprocess.PIPE) return True except OSError: return False
return False
return 0
def has_strace(): """ Return True if this system has strace. """ if platform.system() == 'Windows': # even if windows has strace, it's probably a dodgy cygwin one return False try: subprocess.Popen('strace', stderr=subprocess.PIPE) return True except OSError: return False
subprocess.Popen('strace', stderr=subprocess.PIPE) return True
proc = subprocess.Popen(['strace', '-e', 'trace=stat64'], stderr=subprocess.PIPE) stdout, stderr = proc.communicate() proc.wait() if 'invalid system call' in stderr: return 32 else: return 64
def has_strace(): """ Return True if this system has strace. """ if platform.system() == 'Windows': # even if windows has strace, it's probably a dodgy cygwin one return False try: subprocess.Popen('strace', stderr=subprocess.PIPE) return True except OSError: return False
'trace=open,stat64,execve,exit_group,chdir,mkdir,rename,clone,vfork,fork',
'trace=open,%s,execve,exit_group,chdir,mkdir,rename,clone,vfork,fork' % self._stat_func,
def _do_strace(self, args, outfile, outname): """ Run strace on given command args, sending output to file. Return (status code, list of dependencies, list of outputs). """ shell('strace', '-fo', outname, '-e', 'trace=open,stat64,execve,exit_group,chdir,mkdir,rename,clone,vfork,fork', args, silent=False) cwd = '.' stat...
stat64_match = self._stat64_re.match(line)
stat_match = self._stat_re.match(line)
def _do_strace(self, args, outfile, outname): """ Run strace on given command args, sending output to file. Return (status code, list of dependencies, list of outputs). """ shell('strace', '-fo', outname, '-e', 'trace=open,stat64,execve,exit_group,chdir,mkdir,rename,clone,vfork,fork', args, silent=False) cwd = '.' stat...
elif stat64_match: match = stat64_match
elif stat_match: match = stat_match
def _do_strace(self, args, outfile, outname): """ Run strace on given command args, sending output to file. Return (status code, list of dependencies, list of outputs). """ shell('strace', '-fo', outname, '-e', 'trace=open,stat64,execve,exit_group,chdir,mkdir,rename,clone,vfork,fork', args, silent=False) cwd = '.' stat...
cursor.execute('''
idqueryvalues=[values[0], values[1], values[2], values[3], values[4]] idquery = '''
def get_job_id(self, cursor): job_id = None job_manager_id = self.get_job_manager_instance_id_by_uuid(cursor) count = self.data.get("3") if count is None: count = 0
AND gram5_job_file_info=%s''', values) job_id = cursor.fetchone()[0]
AND gram5_job_file_info=%s''', values
def get_job_id(self, cursor): job_id = None job_manager_id = self.get_job_manager_instance_id_by_uuid(cursor) count = self.data.get("3") if count is None: count = 0
grabFromSVN(options, 'https://vappio.svn.sourceforge.net/svnroot/vappio/trunk/conf', '/opt/conf')
grabFromSVN(options, 'https://vappio.svn.sourceforge.net/svnroot/vappio/trunk/vappio-conf', '/opt/vappio-conf')
def main(options, _args): updateAll = False for o in OPTIONS: if options('general.' + o[0]): break else: updateAll = True if options('general.stow') or updateAll: grabFromSVN(options, 'https://clovr.svn.sourceforge.net/svnroot/clovr/trunk/stow', '/usr/local/stow') if options('general.opt_packages') or updateAll: grabF...
saveTask(readMessages(task))
saveTask(task.readMessages())
def body(self): request = readQuery()
if not pipelineStatus('localhost', clusterName, lambda p : p.name == pipelineName):
if not pipelineStatus('localhost', clusterName, lambda p : p.name == pipelineWrapperName):
def main(_options, args): ## # Because we are trying to mimic another program we have to do some funky work # with the options. We also want to do some kind of validation of the options # so they don't bring up a cluster and try to run it only to find out it # has errored out. args = args[1:] if not args or args ==...
conf = config.configFromMap({'input.INPUT_TAG': inputTagName,
conf = config.configFromMap({'input.PIPELINE_NAME': pipelineName, 'input.INPUT_TAG': inputTagName,
def main(_options, args): ## # Because we are trying to mimic another program we have to do some funky work # with the options. We also want to do some kind of validation of the options # so they don't bring up a cluster and try to run it only to find out it # has errored out. args = args[1:] if not args or args ==...
runPipelineConfig('localhost', clusterName, 'clovr_wrapper', pipelineName, conf)
runPipelineConfig('localhost', clusterName, 'clovr_wrapper', pipelineWrapperName, conf)
def main(_options, args): ## # Because we are trying to mimic another program we have to do some funky work # with the options. We also want to do some kind of validation of the options # so they don't bring up a cluster and try to run it only to find out it # has errored out. args = args[1:] if not args or args ==...
pipelineInfo = pipelineStatus('localhost', clusterName, lambda p : p.name == pipelineName)[0]
pipelineInfo = pipelineStatus('localhost', clusterName, lambda p : p.name == pipelineWrapperName)[0]
def main(_options, args): ## # Because we are trying to mimic another program we have to do some funky work # with the options. We also want to do some kind of validation of the options # so they don't bring up a cluster and try to run it only to find out it # has errored out. args = args[1:] if not args or args ==...
tsk = tsk.setState(task.TASK_FAILED)
raise Exception('Realize Phantom failed')
def main(options, _args): tsk = task.updateTask(task.loadTask(options('general.task_name') ).setState(task.TASK_RUNNING ).addMessage(task.MSG_SILENT, 'Starting uploadTag')) try: srcCluster = loadCluster('localhost', options('general.src_cluster')) dstCluster = loadCluster('localhost', options('general.dst_cluster')) t...
tsk = tsk.setState(task.TASK_FAILED)
raise Exception('Tag data failed')
def main(options, _args): tsk = task.updateTask(task.loadTask(options('general.task_name') ).setState(task.TASK_RUNNING ).addMessage(task.MSG_SILENT, 'Starting uploadTag')) try: srcCluster = loadCluster('localhost', options('general.src_cluster')) dstCluster = loadCluster('localhost', options('general.dst_cluster')) t...
if request['read']: saveTask(task.readMessages())
def body(self): request = readQuery()
if request['read']: for t in tasks: saveTask(t.readMessages())
def body(self): request = readQuery()
for _ret, p in performQuery(host, PIPELINESTATUS_URL, dict(name=name, pipelines=None)) if pred(p)]
for ret, p in performQuery(host, PIPELINESTATUS_URL, dict(name=name, pipelines=None)) if pred(p) and ret]
def pipelineStatus(host, name, pred=lambda _ : True): """ name is the name of the cluster, not pipeline This performs a query to the cluster returning a list dicts containing pipeline status information. pred should be a function called on each pipeline. If pred returns True the pipeline is included, otherwise it is...
raise TryError('Could not chown directory', err)
pass
def makeDirsOnCluster(cluster, dirNames): """ Creates a series of directories on a cluster """ for d in dirNames: runSystemInstanceEx(cluster.master, 'mkdir -p ' + d, None, errorPrintS, user=cluster.config('ssh.user'), options=cluster.config('ssh.options'), log=True) try: runSystemInstanceEx(cluster.master, 'chown -R %...
tagTask = tagfile.tagData('localhost', 'local', options('general.tag_name'), outDir, [outDir], recursive=True, expand=True, append=False, overwrite=True)
tagTask = tagData('localhost', 'local', options('general.tag_name'), outDir, [outDir], recursive=True, expand=True, append=False, overwrite=True)
def main(options, _args): tsk = task.updateTask(task.loadTask(options('general.task_name') ).setState(task.TASK_RUNNING ).addMessage(task.MSG_SILENT, 'Starting realizing')) try: cluster = loadCluster('localhost', 'local') ctype = cluster.config('general.ctype') tf = tagfile.loadTagFile(os.path.join(cluster.config('dir...
fileTag = downloadTag(srcCluster, dstCluster, options('general.tag_name'), baseDir=metadata.get('tag_base_dir', None))
fileTag = downloadTag(srcCluster, dstCluster, options('general.tag_name'))
def main(options, _args): tsk = task.updateTask(task.loadTask(options('general.task_name') ).setState(task.TASK_RUNNING ).addMessage(task.MSG_SILENT, 'Starting download')) srcCluster = loadCluster('localhost', options('general.src_cluster')) dstCluster = loadCluster('localhost', options('general.dst_cluster')) tagFil...
True)
True, {})
def tagInputIfNeeded(inputFile): inputTagName = os.path.basename(inputFile) if not tagExists('local', inputTagName): debugPrint(lambda : 'Tagging input file: ' + inputFile) taskName = tagData('localhost', 'local', inputTagName, os.path.dirname(inputFile), [inputFile], False, False, False, True) blockOnTaskAndFail('loca...
True)
True, {})
def tagDatabaseFiles(databasePath): """ Takes a path to a database like blast expects it. It then goes through the directory finding all files that start with databasePath + '.' and tags them """ tagName = os.path.basename(databasePath) + '_db' baseName = os.path.basename(databasePath) dirName = os.path.dirname(datab...
if options('general.' + o[0]):
if o[0] not in ['vappio_branch', 'clovr_branch'] and options('general.' + o[0]):
def main(options, _args): updateAll = False for o in OPTIONS: if options('general.' + o[0]): break else: updateAll = True clovrBranch = options('general.clovr_branch') vappioBranch = options('general.vappio_branch') try: if options('general.stow') or updateAll: grabFromSVN(options, 'https://clovr.svn.sourceforge.net/...
metadataKeys = [k.split('.', 1)[1] for k in tagFile.keys() if k.startswith('metadata.')] metadata = dict([(k, tagFile('metadata.' + k)) for k in metadataKeys])
def main(options, _args): tsk = task.updateTask(task.loadTask(options('general.task_name') ).setState(task.TASK_RUNNING ).addMessage(task.MSG_SILENT, 'Starting uploadTag')) try: srcCluster = loadCluster('localhost', options('general.src_cluster')) dstCluster = loadCluster('localhost', options('general.dst_cluster')) t...
True)
True, metadata)
def main(options, _args): tsk = task.updateTask(task.loadTask(options('general.task_name') ).setState(task.TASK_RUNNING ).addMessage(task.MSG_SILENT, 'Starting uploadTag')) try: srcCluster = loadCluster('localhost', options('general.src_cluster')) dstCluster = loadCluster('localhost', options('general.dst_cluster')) t...
raise MetricError(metric, stderr)
raise MetricError(metric, stderr.getvalue())
def _errback(metric, stderr): raise MetricError(metric, stderr)
commands.runSingleProgramEx(os.path.join(SGE_ROOT, 'util', 'arch'), stdoutf=sio.write, stderrf=None) arch = sio.getvalue().strip() sgeRootBin = os.path.join('/opt', 'sge', 'bin', arch)
sgeRootBin = os.path.join(SGE_ROOTBIN)
def body(self): form = cgi.FieldStorage() host = form['host'].value sio = StringIO.StringIO() commands.runSingleProgramEx(os.path.join(SGE_ROOT, 'util', 'arch'), stdoutf=sio.write, stderrf=None) arch = sio.getvalue().strip() sgeRootBin = os.path.join('/opt', 'sge', 'bin', arch)
vmWareDir = 'clovr-vmware.beta-%s' % options('general.version')
vmWareDir = 'clovr-vmware.%s' % options('general.version')
def main(options, _args): runSystemEx('svn copy https://clovr.svn.sourceforge.net/svnroot/clovr/trunk https://clovr.svn.sourceforge.net/svnroot/clovr/tags/%s -m "Cutting release %s"' % (options('general.version'), options('general.version')), log=True) runSystemEx('svn copy https://vappio.svn.sourceforge.net/svnroot/va...
runSystemEx('mv VMware_conversion/shared/converted_img.vmdk %s' % os.path.join(vmWareDir, 'clovr.9-04.x86-64.beta-%s.vmdk' % options('general.version')))
runSystemEx('mv VMware_conversion/shared/converted_img.vmdk %s' % os.path.join(vmWareDir, 'clovr.9-04.x86-64.%s.vmdk' % options('general.version')))
def main(options, _args): runSystemEx('svn copy https://clovr.svn.sourceforge.net/svnroot/clovr/trunk https://clovr.svn.sourceforge.net/svnroot/clovr/tags/%s -m "Cutting release %s"' % (options('general.version'), options('general.version')), log=True) runSystemEx('svn copy https://vappio.svn.sourceforge.net/svnroot/va...
groups = listGroups()
groups = [g[0] for g in listGroups()]
def main(options, _args): if options('general.cert') and options('general.pk'): runSystemEx('cp %s /tmp/ec2-cert.pem' % options('general.cert')) runSystemEx('cp %s /tmp/ec2-pk.pem' % options('general.pk')) runSystemEx('chmod +r /tmp/*.pem') if 'vappio_00' not in listKeypairs(): addKeypair('vappio_00') groups = listGro...
accountnumber)
accountNumber)
def main(options, _args): if options('general.cert') and options('general.pk'): runSystemEx('cp %s /tmp/ec2-cert.pem' % options('general.cert')) runSystemEx('cp %s /tmp/ec2-pk.pem' % options('general.pk')) runSystemEx('chmod +r /tmp/*.pem') if 'vappio_00' not in listKeypairs(): addKeypair('vappio_00') groups = listGro...
runSystemEx('ssh-keygen -f /mnt/keys/devel1.pem -P ""')
runSingleProgramEx('ssh-keygen -f /mnt/keys/devel1.pem -P ""', None, None) print print print 'Setup complete.' print '*** Remember, currently you have to do this every time you restart the VM'
def main(options, _args): if options('general.cert') and options('general.pk'): runSystemEx('cp %s /tmp/ec2-cert.pem' % options('general.cert')) runSystemEx('cp %s /tmp/ec2-pk.pem' % options('general.pk')) runSystemEx('chmod +r /tmp/*.pem') if 'vappio_00' not in listKeypairs(): addKeypair('vappio_00') groups = listGro...
except Exeption, err:
except Exception, err:
def convertImage(chan): options, rchan = chan.receive() try: runSingleProgramEx('vmplayer VMware_conversion/conversion_image.vmx', stdoutf=None, stderrf=None, log=True) rchan.send(None) except Exeption, err: rchan.sendError(err)
return taskToDict(task)
return json.dumps([True, taskToDict(task)])
def body(self): request = readQuery()
runSingleProgramEx('ec2-modify-image-attribute %s --launch-permission -a all' % ami, stdouf=sys.stdout.write, stderrf=sys.stderr.write, log=True)
runSingleProgramEx('ec2-modify-image-attribute %s --launch-permission -a all' % ami, stdoutf=sys.stdout.write, stderrf=sys.stderr.write, log=True)
def bundleAMI(chan): options, rchan = chan.receive() try: cmd = ['ec2-bundle-image', '-c ${general.cert}', '-k ${general.key}', '-u ${general.user}', '--kernel ${general.kernel}', '-i ${general.image}', '-d ${general.dest}', '-p ${general.image}', '-r ${general.arch}'] if options('general.ec2cert'): cmd.append('--ec2c...
try: srcCluster = loadCluster('localhost', options('general.src_cluster')) dstCluster = loadCluster('localhost', options('general.dst_cluster')) fileList = downloadTag(srcCluster, dstCluster, options('general.tag_name')) tsk = task.updateTask(tsk.progress()) tagTaskName = tagData('localhost',
srcCluster = loadCluster('localhost', options('general.src_cluster')) dstCluster = loadCluster('localhost', options('general.dst_cluster')) tagFile = tag.queryTag('localhost', options('general.src_cluster'), options('general.tag_name')) metadataKeys = [k.split('.', 1)[1] for k in tagFile.keys() if k.startswith('metad...
def main(options, _args): tsk = task.updateTask(task.loadTask(options('general.task_name') ).setState(task.TASK_RUNNING ).addMessage(task.MSG_SILENT, 'Starting download')) try: srcCluster = loadCluster('localhost', options('general.src_cluster')) dstCluster = loadCluster('localhost', options('general.dst_cluster')) fi...
True) endState, tsk = blockOnTaskAndForward('localhost', options('general.dst_cluster'), tagTaskName, tsk) if endState == task.TASK_FAILED: tsk = task.updateTask(tsk.setState(task.TASK_FAILED)) else: tsk = task.updateTask(tsk.progress().setState(task.TASK_COMPLETED)) except Exception, err: tsk = tsk.setState(task.TASK_...
True, metadata) endState, tsk = task_utils.blockOnTaskAndForward('localhost', options('general.dst_cluster'), tagTaskName, tsk) if endState == task.TASK_FAILED: raise Exception('Taging failed') else: tsk = task.updateTask(tsk.progress())
def main(options, _args): tsk = task.updateTask(task.loadTask(options('general.task_name') ).setState(task.TASK_RUNNING ).addMessage(task.MSG_SILENT, 'Starting download')) try: srcCluster = loadCluster('localhost', options('general.src_cluster')) dstCluster = loadCluster('localhost', options('general.dst_cluster')) fi...
runCatchError(lambda : main(*buildConfigN(OPTIONS)),
runCatchError(lambda : task_utils.runTaskMain(main, *buildConfigN(OPTIONS)),
def main(options, _args): tsk = task.updateTask(task.loadTask(options('general.task_name') ).setState(task.TASK_RUNNING ).addMessage(task.MSG_SILENT, 'Starting download')) try: srcCluster = loadCluster('localhost', options('general.src_cluster')) dstCluster = loadCluster('localhost', options('general.dst_cluster')) fi...
if conf('pipeline_conf', default=None) is not None: fconf = configFromStream(open(conf('pipeline_conf')))
if conf('CONFIG_FILE', default=None) is not None: fconf = configFromStream(open(conf('CONFIG_FILE')))
def confIfPipelineConfigSet(conf, options): """ Takes a conf, checks to see if a pipeline conf file is specified, if so it loads it up and applies it OVER any options specified on the command line. This may seem counter intuitive but it makes other things easier, for example a pipeline redefining anything in the machi...
return configFromMap(m, configFromStream(open(conf('pipeline_conf')), conf))
return configFromMap(m, configFromStream(open(conf('CONFIG_FILE')), conf))
def confIfPipelineConfigSet(conf, options): """ Takes a conf, checks to see if a pipeline conf file is specified, if so it loads it up and applies it OVER any options specified on the command line. This may seem counter intuitive but it makes other things easier, for example a pipeline redefining anything in the machi...
if options('general.name'):
if not options('general.list'):
def main(options, _args): if options('general.name'): cluster = loadCluster(options('general.host'), options('general.name'), options('general.partial')) print '\t'.join(['MASTER'] + instanceToList(cluster.master)) for e in cluster.execNodes: print '\t'.join(['EXEC'] + instanceToList(e)) for e in cluster.dataNodes: p...
elif options('general.list'):
else:
def main(options, _args): if options('general.name'): cluster = loadCluster(options('general.host'), options('general.name'), options('general.partial')) print '\t'.join(['MASTER'] + instanceToList(cluster.master)) for e in cluster.execNodes: print '\t'.join(['EXEC'] + instanceToList(e)) for e in cluster.dataNodes: p...
else: raise Exception('Failed to provide a cluster name or to list them')
def main(options, _args): if options('general.name'): cluster = loadCluster(options('general.host'), options('general.name'), options('general.partial')) print '\t'.join(['MASTER'] + instanceToList(cluster.master)) for e in cluster.execNodes: print '\t'.join(['EXEC'] + instanceToList(e)) for e in cluster.dataNodes: p...
if options('general.read'): debugPrint(lambda : 'Will mark any messages unread as read')
def main(options, tasks): if options('general.debug'): logging.DEBUG = True if options('general.read'): debugPrint(lambda : 'Will mark any messages unread as read') if not tasks: debugPrint(lambda : 'No task names provided, loading all from database') tasks = loadAllTasks(options('general.host'), options('general.nam...
tasks = loadAllTasks(options('general.host'), options('general.name'), read=options('general.read'))
tasks = loadAllTasks(options('general.host'), options('general.name'))
def main(options, tasks): if options('general.debug'): logging.DEBUG = True if options('general.read'): debugPrint(lambda : 'Will mark any messages unread as read') if not tasks: debugPrint(lambda : 'No task names provided, loading all from database') tasks = loadAllTasks(options('general.host'), options('general.nam...
tasks = [loadTask(options('general.host'), options('general.name'), t, read=options('general.read'))
tasks = [loadTask(options('general.host'), options('general.name'), t)
def main(options, tasks): if options('general.debug'): logging.DEBUG = True if options('general.read'): debugPrint(lambda : 'Will mark any messages unread as read') if not tasks: debugPrint(lambda : 'No task names provided, loading all from database') tasks = loadAllTasks(options('general.host'), options('general.nam...
metadata=json.loads(options('general.metadata')),
metadata=json.loads(options('general.metadata').decode("string_escape")),
def main(options, files): tsk = task.updateTask(task.loadTask(options('general.task_name') ).setState(task.TASK_RUNNING ).addMessage(task.MSG_SILENT, 'Starting tagging')) cluster = loadCluster('localhost', 'local') tagData(cluster.config('dirs.tag_dir'), options('general.tag_name'), options('general.tag_base_dir'), f...
overwrite=True)
overwrite=True, metadata=metadata)
def main(options, _args): tsk = task.updateTask(task.loadTask(options('general.task_name') ).setState(task.TASK_RUNNING ).addMessage(task.MSG_SILENT, 'Starting realizing')) try: cluster = loadCluster('localhost', 'local') ctype = cluster.config('general.ctype') tf = tagfile.loadTagFile(os.path.join(cluster.config('dir...
machineConf = createDataFile(cluster.config, [EXEC_NODE], outFile='/tmp/exec.machine.conf') dataFile = createExecDataFile(cluster.config, cluster.master, machineConf)
dataFile = createExecDataFile(cluster.config, cluster.master, '/tmp/machine.conf')
def startExecNodes(cluster, numExec, reporter=None): """ This starts a number of exec nodes. It will add them to the cluster and returnst he cluster It is valid to give 0 for numExec. """ ## # Function body if numExec: machineConf = createDataFile(cluster.config, [EXEC_NODE], outFile='/tmp/exec.machine.conf') dataF...
val = replaceStr(f(val), conf)
val = replaceStr(val, conf)
def c(conf): val = x for f in funcs: try: val = replaceStr(f(val), conf) except TypeError: pass
runSystemEx('gzip ' + outTar, log=True) metadata = func.updateDict(metadata, {'compressed': True, 'compressed_file': outGzip})
if os.path.exists(outTar): runSystemEx('gzip ' + outTar, log=True) metadata = func.updateDict(metadata, {'compressed': True, 'compressed_file': outGzip})
def tagData(tagsDir, tagName, tagBaseDir, files, recursive, expand, compress, append, overwrite, metadata=None, filterF=None): """ Tag a list of files with the name. The files can contain direcotires, and if recursive is set the contends of the directories will become part of the tag rather than just the name tagBase...
def getSizeOfCwd():
def getSizeOfDir(d):
def getSizeOfCwd(): stdoutL = [] commands.runSingleProgramEx('du -ks .', stdoutf=stdoutL.append, stderrf=None, log=False) return int(''.join(stdoutL).split()[0])
commands.runSingleProgramEx('du -ks .',
commands.runSingleProgramEx('du -ks ' + d,
def getSizeOfCwd(): stdoutL = [] commands.runSingleProgramEx('du -ks .', stdoutf=stdoutL.append, stderrf=None, log=False) return int(''.join(stdoutL).split()[0])
def monitorDownload(pr, downloaderChan, minRate):
def monitorDownload(pr, downloaderChan, downloadDir, minRate):
def monitorDownload(pr, downloaderChan, minRate): sizeSamples = [] while True: baseSize = getSizeOfCwd() time.sleep(SAMPLE_RATE) ## # If the program exited and exited correctly, then we're good # otherwise take another sample size and see if we should terminate if pr.exitCode is not None: ret = downloaderChan.receive()...
baseSize = getSizeOfCwd()
baseSize = getSizeOfDir(downloadDir)
def monitorDownload(pr, downloaderChan, minRate): sizeSamples = [] while True: baseSize = getSizeOfCwd() time.sleep(SAMPLE_RATE) ## # If the program exited and exited correctly, then we're good # otherwise take another sample size and see if we should terminate if pr.exitCode is not None: ret = downloaderChan.receive()...
currentSize = getSizeOfCwd() - baseSize
currentSize = getSizeOfDir(downloadDir) - baseSize
def monitorDownload(pr, downloaderChan, minRate): sizeSamples = [] while True: baseSize = getSizeOfCwd() time.sleep(SAMPLE_RATE) ## # If the program exited and exited correctly, then we're good # otherwise take another sample size and see if we should terminate if pr.exitCode is not None: ret = downloaderChan.receive()...
return monitorDownload(pr, downloaderChan, options('general.min_rate'))
return monitorDownload(pr, downloaderChan, options('general.base_dir'), options('general.min_rate'))
def attemptDownload(options, url): pr = commands.ProgramRunner('wget -c --quiet -P %s %s' % (options('general.base_dir'), url), stdoutf=sys.stdout.write, stderrf=sys.stderr.write, log=True) downloaderChan = threads.runThreadWithChannel(runDownloader).channel.sendWithChannel(pr) ## # sleep for a second so the program c...
cfg.append((key, value[:-1]))
cfg.append((key, value.rstrip('\n')))
def configListFromStream(stream): """ Constructs a list of [(key, value)] from an ini-like file """ ## # We are just going to read the config file into a map and use configFromMap cfg = [] ## # Default section section = '' for line in stream: line = line.lstrip() if not line or line[0] == '#': # A comment or empty line...
d.errback()
d.errback(Exception('Waiting for request failed'))
def _timeout(): self.mq.unsubscribe(retQueue) d.errback()
for line in open(os.path.join(configDir, 'repositories')):
for line in (l for l in open(os.path.join(configDir, 'repositories')) if l.strip()):
def loadRepositories(configDir): """ Returns a map of repos names to record objects identifying the repos. Each record object contains: - name - rType (git, svn instantiated) - repoUrl - exportType - branch Everything but the logs is loaded here """ repos = {} for line in open(os.path.join(configDir, 'repositories'))...
for line in open(os.path.join(configDir, 'branches')):
for line in (l for l in open(os.path.join(configDir, 'branches')) if l.strip()):
def loadRepositories(configDir): """ Returns a map of repos names to record objects identifying the repos. Each record object contains: - name - rType (git, svn instantiated) - repoUrl - exportType - branch Everything but the logs is loaded here """ repos = {} for line in open(os.path.join(configDir, 'repositories'))...
for line in open(os.path.join(configDir, 'checkouts')):
for line in (l for l in open(os.path.join(configDir, 'checkouts')) if l.strip()):
def loadRepositories(configDir): """ Returns a map of repos names to record objects identifying the repos. Each record object contains: - name - rType (git, svn instantiated) - repoUrl - exportType - branch Everything but the logs is loaded here """ repos = {} for line in open(os.path.join(configDir, 'repositories'))...
tsk = addExecInstances(cl, options, tsk)
tsk = addExecInstances(options, cl, tsk)
def main(options, _args): options = configFromMap( {'cluster': {'master_groups': [f.strip() for f in options('cluster.master_groups').split(',')], 'exec_groups': [f.strip() for f in options('cluster.exec_groups').split(',')], } }, options) ctype = ec2control tsk = task.loadTask(options('general.task_name')) tsk = task...
return configFromMap(performQuery(host, QUERYTAG_URL, dict(name=name, tag_name=tagName))[0], lazy=True)
return configFromMap(performQuery(host, QUERYTAG_URL, dict(name=name, tag_name=tagName))[tagName], lazy=True)
def queryTag(host, name, tagName): ## # A tag may contain some keys that shouldn't be evaluated return configFromMap(performQuery(host, QUERYTAG_URL, dict(name=name, tag_name=tagName))[0], lazy=True)
'--clovr-branch=' + conf('dev.clovr_branch', default='trunk'), '--vappio-branch=' + conf('dev.vappio_branch', default='trunk'),
'--clovr-branch=' + conf('dev.clovr_branch', default=''), '--vappio-branch=' + conf('dev.vappio_branch', default=''),
def startUpAllNodes(conf): """ Things that need to be done for all nodes: 1 - Go through /usr/local/stow and /opt/opt-packages installing all packages 2 - List through all .py files in /opt/config_policies and run them (eventually this directory should probably be split up by node type) """ if conf('dev.update_dirs', ...
if options('general.num'): addInstances('localhost', options('general.name'), options('general.num'), options('general.update_dirs'))
def main(options, _args): options = configFromMap( {'cluster': {'master_groups': [f.strip() for f in options('cluster.master_groups').split(',')], 'exec_groups': [f.strip() for f in options('cluster.exec_groups').split(',')], } }, options) ctype = ec2control cl = Cluster(options('general.name'), ctype, options) try: s...
if options('general.num'): addInstances('localhost', options('general.name'), options('general.num'), options('general.update_dirs'))
def main(options, _args): options = configFromMap( {'cluster': {'master_groups': [f.strip() for f in options('cluster.master_groups').split(',')], 'exec_groups': [f.strip() for f in options('cluster.exec_groups').split(',')], } }, options) ctype = ec2control cl = Cluster(options('general.name'), ctype, options) try: s...
print '\t'.join(['EXEC', e.publicDNS, e.state])
print '\t'.join(['EXEC', e.instanceId or e.spotInstanceId or 'Undefined', e.publicDNS or 'Undefined', e.state or 'Undefined'])
def main(options, _args): if options('general.name'): cluster = loadCluster(options('general.host'), options('general.name'), options('general.partial')) print '\t'.join(['MASTER', cluster.master.publicDNS, cluster.master.state]) for e in cluster.execNodes: print '\t'.join(['EXEC', e.publicDNS, e.state]) for e in clu...