rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
print '\t'.join(['DATA', e.publicDNS, e.state]) | print '\t'.join(['DATA', 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... |
cluster.config = configFromMap( {'cluster': {'master_groups': [f.strip() for f in cluster.config('cluster.master_groups').split(',')], 'exec_groups': [f.strip() for f in cluster.config('cluster.exec_groups').split(',')] }, 'general': {'ctype': 'ec2'}}, cluster.config) | def main(options, _args): try: cluster = load('local') except ClusterDoesNotExist: options = configFromMap({'general': {'ctype': 'ec2'}}, configFromStream(open('/tmp/machine.conf'), configFromEnv(options))) options = configFromMap( {'cluster': {'master_groups': [f.strip() for f in options('cluster.master_groups').split... | |
return [i.instanceId or i.spotInstanceId or 'Undefined', i.publicDNS or 'Undefined', i.state or 'Undefined'] | return [i.instanceId or i.spotRequestId or 'Undefined', i.publicDNS or 'Undefined', i.state or 'Undefined'] | def instanceToList(i): return [i.instanceId or i.spotInstanceId or 'Undefined', i.publicDNS or 'Undefined', i.state or 'Undefined'] |
fileList = downloadTag(srcCluster, dstCluster, options('general.tag_name')) | fileList = downloadTag(srcCluster, dstCluster, options('general.tag_name'), baseDir=metadata.get('tag_base_dir', None)) | 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... |
finally: os.remove(dataFile) | def startMaster(cluster, reporter=None, devMode=False, releaseCut=False): """ This starts a master on the given cluster and returns the cluster with the master value set. reporter is a function that gets called at various points with the master. The master is passed as a list with 1 element This mutates the cluster o... | |
'/tmp', | def _setupInstance(chan): i, rchan = chan.receive() try: try: scpToEx(i.publicDNS, '/tmp/machine.conf', '/tmp', user=cluster.config('ssh.user'), options=cluster.config('ssh.options')) except: scpToEx(i.publicDNS, '/tmp/machine.conf', '/tmp', user=cluster.config('ssh.user'), options=cluster.config('ssh.options')) | |
return self.update(completedSelfs=self.completedTaskss + inc) | return self.update(completedSelfs=self.completedTasks + inc) | def progress(self, inc=1): return self.update(completedSelfs=self.completedTaskss + inc) |
if conf('cluster.cluster_private_key') + '.pub': | if os.path.exists(conf('cluster.cluster_private_key') + '.pub'): | def instantiateCredential(conf, cred): certFile = os.path.join(conf('general.secure_tmp'), cred.name + '_cert.pem') keyFile = os.path.join(conf('general.secure_tmp'), cred.name + '_key.pem') if not os.path.exists(certFile) and not os.path.exists(keyFile): tmpCertFile = os.path.join(conf('general.secure_tmp'), cred.name... |
self.assertRaises(Exception, test_view('google_maps')) | test_view('google_maps') | def test0005views(self): ''' Test views. ''' self.assertRaises(Exception, test_view('google_maps')) |
sa.not_(db.machines.name.like('talos-r3%')), | sa.or_(db.machines.name.like('talos-r3%'), db.machines.name.like('talos-rev2-tiger%')), | def getTestData(series, start_time): q = sa.select( [db.test_runs.machine_id, db.builds.ref_build_id, db.test_runs.date_run, db.test_runs.average, db.builds.ref_changeset, db.test_runs.run_number, db.builds.branch_id], sa.and_( db.test_runs.test_id == series.test_id, db.builds.branch_id == series.branch_id, db.machines... |
sa.not_(db.machines.name.like('talos-r3%')), | sa.or_(db.machines.name.like('talos-r3%'), db.machines.name.like('talos-rev2-tiger%')), | def getTestSeries(branches, start_date, test_names): # Find all the Branch/OS/Test combinations if len(test_names) > 0: test_clause = db.tests.pretty_name.in_(test_names) else: test_clause = True q = sa.select( [db.branches.id, db.branches.name, db.os_list.id, db.os_list.name, db.tests.id, db.tests.pretty_name], sa.and... |
sa.not_(db.machines.name.like('talos-r3%')), | sa.or_(db.machines.name.like('talos-r3%'), db.machines.name.like('talos-rev2-tiger%')), | def getMachinesForTest(series): key = (series.os_id, series.branch_id, series.test_id) if key in _machines_cache: return _machines_cache[key] q = sa.select([db.machines.id], sa.and_( db.test_runs.machine_id == db.machines.id, db.builds.id == db.test_runs.build_id, db.builds.branch_id == series.branch_id, db.tests.id =... |
config.set('main', 'regression_emails', ",".join(option.addresses)) | config.set('main', 'regression_emails', ",".join(options.addresses)) | def save(self, errors=False): try: self.saveWarningHistory() except: log.exception("Error saving warning history") |
config.set('main', 'machine_emails', ",".join(option.machine_addresses)) | config.set('main', 'machine_emails', ",".join(options.machine_addresses)) | def save(self, errors=False): try: self.saveWarningHistory() except: log.exception("Error saving warning history") |
direction = "decrease" | def formatMessage(self, state, series, good, bad, html=False): if state == "machine": good = bad.last_other | |
direction = "increase" | def formatMessage(self, state, series, good, bad, html=False): if state == "machine": good = bad.last_other | |
direction = "decrease" | def formatSubject(self, state, series, good, bad): if state == "machine": good = bad.last_other | |
direction = "increase" | def formatSubject(self, state, series, good, bad): if state == "machine": good = bad.last_other | |
id: An account identifier | id: An account identifier (which may or may not start with 'acct:') | def lookup(self, id): """Look up a webfinger resource by (email-like) id. |
id = self._normalize_id(id) addr_spec, local_part, domain = self._parse_id(id) | local_part, domain = self._parse_id(id) webfinger_id = 'acct:%s@%s' % (local_part, domain) | def lookup(self, id): """Look up a webfinger resource by (email-like) id. |
self._get_service_description(link.template, id)) | self._get_service_description(link.template, webfinger_id)) | def lookup(self, id): """Look up a webfinger resource by (email-like) id. |
self._get_service_description(link.href, id)) | self._get_service_description(link.href, webfinger_id)) | def lookup(self, id): """Look up a webfinger resource by (email-like) id. |
def _normalize_id(self, id): """Normalize the account identifier. Args: id: An acctount identifier Returns: A normalized account identifier, if possible. """ if id.startswith('acct://'): return id[7:] elif id.startswith('acct:'): return id[5:] return id | def lookup(self, id): """Look up a webfinger resource by (email-like) id. | |
The tuple (addr_spec, local_part, domain) if it can be parsed | The tuple (local_part, domain) if it can be parsed | def _parse_id(self, id): """Treats an identifier as a RFC2822 addr-spec and splits it. |
return addr_spec, match.group(1), match.group(2) | return match.group(1), match.group(2) | def _parse_id(self, id): """Treats an identifier as a RFC2822 addr-spec and splits it. |
logger.debug('Updated %s' % ZODB.utils.oid_repr(oid)) | logger.debug('Updated OID %s' % ZODB.utils.oid_repr(oid)) | def __call__(self): try: count = 0 t = self.__new_transaction() |
def __iter__(self): """Define a empty iterator to fix unpickling of missing Interfaces that have been used to do alsoProvides on a another pickled object. """ return NullIterator() | __metaclass__ = IterableClass | def next(self): raise StopIteration |
if x.value[0].type == TEXT: | if x.value.type == TEXT: | def xmlnode(self, indent=0): out = [] write = out.append if self.type == ROOT: write('<?xml version="1.0" encoding="UTF-8"?>') |
elif x.value[0].type == EMPTY: | elif x.value.type == EMPTY: | def xmlnode(self, indent=0): out = [] write = out.append if self.type == ROOT: write('<?xml version="1.0" encoding="UTF-8"?>') |
sandbox.filter_syscalls = 0 sandbox.file_check = 9 | sandbox.filter_syscalls = 1 sandbox.allow_fork = True sandbox.file_check = 1 sandbox.allow_path = ['/etc/', '/lib/', '/usr/', '/tmp/', source_filename, executable_filename] | def compile(self): """Tries to compile the specified submission. |
except: Utils.log("Couldn't spawn sandbox when trying to compile submission %s" % (self.submission.couch_id)) | except Exception as e: Utils.log("Couldn't spawn sandbox, raised exception %s" % (repr(e))) | def compile(self): """Tries to compile the specified submission. |
def get_exit_style(self): | def get_exit_status(self): | def get_exit_style(self): self.get_status_list() if 'XX' in self.status_list: return self.EXIT_SANDBOX_ERROR elif 'OK' in self.status_list: return self.EXIT_OK elif 'FO' in self.status_list: return self.EXIT_SYSCALL elif 'FA' in self.status_list: return self.EXIT_FILE_ACCESS elif 'TO' in self.status_list: return self.E... |
os.chmod(real_path, stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH) | mod |= stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH os.chmod(real_path, mod) | def create_file(self, path, executable = False): if executable: Utils.log("Creating executable file %s in sandbox" % (path), Utils.Logger.SEVERITY_DEBUG) else: Utils.log("Creating plain file %s in sandbox" % (path), Utils.Logger.SEVERITY_DEBUG) real_path = self.relative_path(path) fd = open(real_path, 'w') if executabl... |
def finish_single_evaluation(self, test_number, success, outcome = 0, text = ""): | def finish_single_execution(self, test_number, success, outcome = 0, text = ""): | def finish_single_evaluation(self, test_number, success, outcome = 0, text = ""): self.safe_delete_sandbox() if not success: return False self.submission.evaluation_outcome[test_number] = outcome self.submission.evaluation_text[test_number] = text return True |
return self.finish_single_evaluation(test_number, True, 0.0, "Execution timed out\n") | return self.finish_single_execution(test_number, True, 0.0, "Execution timed out\n") | def execute_single(self, test_number): self.safe_create_sandbox() self.safe_create_file_from_storage(self.executable_filename, self.submission.executables[self.executable_filename], executable = True) self.safe_create_file_from_storage("input.txt", self.submission.task.testcases[test_number][0]) |
return self.finish_single_evaluation(test_number, True, 0.0, "Execution killed with signal %d\n" % (signal)) | return self.finish_single_execution(test_number, True, 0.0, "Execution killed with signal %d\n" % (signal)) | def execute_single(self, test_number): self.safe_create_sandbox() self.safe_create_file_from_storage(self.executable_filename, self.submission.executables[self.executable_filename], executable = True) self.safe_create_file_from_storage("input.txt", self.submission.task.testcases[test_number][0]) |
return self.finish_single_evaluation(test_number, False) | return self.finish_single_execution(test_number, False) | def execute_single(self, test_number): self.safe_create_sandbox() self.safe_create_file_from_storage(self.executable_filename, self.submission.executables[self.executable_filename], executable = True) self.safe_create_file_from_storage("input.txt", self.submission.task.testcases[test_number][0]) |
return self.finish_single_evaluation(test_number, True, outcome, text) | return self.finish_single_execution(test_number, True, outcome, text) | def execute_single(self, test_number): self.safe_create_sandbox() self.safe_create_file_from_storage(self.executable_filename, self.submission.executables[self.executable_filename], executable = True) self.safe_create_file_from_storage("input.txt", self.submission.task.testcases[test_number][0]) |
for t in c.tasks: | for t in self.tasks: | def get_task(self, task_name): """ Returns the first task in the contest with the given name. """ for t in c.tasks: if t.name == task_name: return t raise KeyError("Task not found") |
ht = db[self.couch_id] | try: ht = db[self.couch_id] except couchdb.ResourceNotFound: ht = dict() ht["document_type"] = self.document_type | def to_couch(self): db = Utils.get_couchdb_database() if self.couch_id == None: ht = dict() ht["document_type"] = self.document_type else: ht = db[self.couch_id] |
self.jd = JobDispatcher(queue, workers) jd.start() | self.jd = JobDispatcher(self.queue, self.workers) self.jd.start() | def __init__(self, contest, listen_address = None, listen_port = None): self.contest = contest if listen_address == None: listen_address = Configuration.evaluation_server[0] if listen_port == None: listen_port = Configuration.evaluation_server[1] |
dig = FSL.put("ciao.txt", "Interesting file") print "Put file ciao.txt, digest = %s" % (dig) res = FSL.get(dig, "ciao2.txt") print "Got file ciao2.txt, value =", res | dig = FSL.put(filename, "Interesting file") print "Put file %s, digest = %s" % (filename, dig) os.remove(filename) res = FSL.get(dig, filename) print "Got file %s, value = %s" % (filename, res) content = open(filename).read() if content == "1\n2\n3\n": print "Correct" else: print "Wrong result" os.remove(filename) | def random_bind(self, bindSocket, address): ok = False while not ok: try: port = random.randint(10000, 60000) bindSocket.bind((address, port)) ok = True except socket.error as (errno, strerror): if errno != os.errno.EADDRINUSE: raise return port |
self.port = random.randint(16000, 17000) | self.bind_address = '' | def __init__(self): self.port = random.randint(16000, 17000) self.local_address = 'localhost' self.remote_address = 'localhost' self.fs = xmlrpclib.ServerProxy('http://localhost:8000') |
putSocket.bind(('', self.port)) | self.random_bind(putSocket, self.bind_address) | def put(self, path): putSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) putSocket.bind(('', self.port)) putSocket.listen(1) with open(path) as putFile: ft = FilePutThread(putSocket, putFile) ft.start() res = self.fs.put(self.local_address, self.port) putSocket.close() return res |
getSocket.bind(('', self.port+1)) | self.random_bind(getSocket, self.bind_address) | def get(self, dig, path): getSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) getSocket.bind(('', self.port+1)) getSocket.listen(1) with open(path, "w") as getFile: ft = FileGetThread(getSocket, getFile) ft.start() res = self.fs.get(self.local_address, self.port+1, dig) ft.join() getSocket.close() return res |
executable_present = self.sandbox.file_exists(executable_filename) | def compile(self): """Tries to compile the specified submission. | |
else: Utils.log("Compilation successfully finished") return self.finish_compilation(True, True, "OK %s\nCompiler output:\n%s" % (self.sandbox.get_stats(), stderr)) | Utils.log("Compilation successfully finished") return self.finish_compilation(True, True, "OK %s\nCompiler output:\n%s" % (self.sandbox.get_stats(), stderr)) | def compile(self): """Tries to compile the specified submission. |
command = "/usr/bin/gcc -DEVAL -static -O2 -lm -o %s %s" % (executable_filename, source_filename) | command = ["/usr/bin/gcc", "-DEVAL", "-static", "-O2", "-lm", "-o", executable_filename, source_filename] | def compile(self, submission): """Tries to compile the specified submission. |
command = "/usr/bin/g++ -DEVAL -static -O2 -o %s %s" % (executable_filename, source_filename) | command = ["/usr/bin/g++", "-DEVAL", "-static", "-O2", "-o", executable_filename, source_filename] | def compile(self, submission): """Tries to compile the specified submission. |
command = "/usr/bin/gpc -dEVAL -XS -O2 -o %s %s" % (executable_filename, source_filename) | command = ["/usr/bin/gpc", "-dEVAL", "-XS", "-O2", "-o%s" % (executable_filename), source_filename] | def compile(self, submission): """Tries to compile the specified submission. |
Utils.log("Starting compiling submission %s with command line: %s" % (submission.couch_id, command)) | sandbox.stdout_file = sandbox.relative_path("compiler_stdout.txt") sandbox.stderr_file = sandbox.relative_path("compiler_stderr.txt") Utils.log("Compiling submission %s" % (submission.couch_id)) | def compile(self, submission): """Tries to compile the specified submission. |
compilation_return = sandbox.execute(command.split(" ")) | sandbox.execute(command) | def compile(self, submission): """Tries to compile the specified submission. |
compilation_return = 1 if compilation_return == 0: | Utils.log("Couldn't spawn sandbox when trying to compile submission %s" % (submission.couch_id)) return False executable_present = True try: sandbox.stat_file(executable_filename) except IOError: executable_present = False if sandbox.get_exit_status() == Sandbox.EXIT_OK and executable_present: | def compile(self, submission): """Tries to compile the specified submission. |
Utils.log("Compilation for submission %s failed" % (submission.couch_id)) submission.compilation_result = "Failed" submission.to_couch() | pass | def compile(self, submission): """Tries to compile the specified submission. |
if self.filter_syscalls != None: res += ["-f", str(self.filter_syscalls)] | if self.filter_syscalls != None and self.filter_syscalls > 0: res += ["-%s" % ("f" * self.filter_syscall)] | def build_box_options(self): res = list() if self.file_check != None: res += ["-a", str(self.file_check)] if self.chdir != None: res += ["-c", self.chdir] if self.preserve_env: res += ["-e"] for var in self.inherit_env: res += ["-E", var] for var, value in self.set_env: res += ["-E", "%s=%s" % (var, value)] if self.fil... |
if log not in self: | if "log" not in self.__dict__: | def get_log(self): if log not in self: self.log = list() try: with self.get_file(self.info_file) as log_file: for line in log_file: self.log.append(line.split(":", 2)) except IOError: raise IOError("Error while reading execution log") return self.log |
self.log.append(line.split(":", 2)) | self.log.append(line.strip().split(":", 2)) | def get_log(self): if log not in self: self.log = list() try: with self.get_file(self.info_file) as log_file: for line in log_file: self.log.append(line.split(":", 2)) except IOError: raise IOError("Error while reading execution log") return self.log |
if status_list not in self: | if "status_list" not in self.__dict__: | def get_status_list(self): if status_list not in self: self.status_list = list() for k, v in self.get_log(): if k == 'status': self.status_list.append(v) return self.status_list |
elif 'OK' in self.status_list: return self.EXIT_OK | def get_exit_status(self): self.get_status_list() if 'XX' in self.status_list: return self.EXIT_SANDBOX_ERROR elif 'OK' in self.status_list: return self.EXIT_OK elif 'FO' in self.status_list: return self.EXIT_SYSCALL elif 'FA' in self.status_list: return self.EXIT_FILE_ACCESS elif 'TO' in self.status_list: return self.... | |
return self.EXIT_SANDBOX_ERROR | return self.EXIT_OK | def get_exit_status(self): self.get_status_list() if 'XX' in self.status_list: return self.EXIT_SANDBOX_ERROR elif 'OK' in self.status_list: return self.EXIT_OK elif 'FO' in self.status_list: return self.EXIT_SYSCALL elif 'FA' in self.status_list: return self.EXIT_FILE_ACCESS elif 'TO' in self.status_list: return self.... |
for i in CouchObject._to_copy: | for i in self._to_copy: | def to_couch(self): ht = dict() for i in CouchObject._to_copy: if i in self.__dict__: ht[i] = self.__dict__[i] for i in CouchObject._to_copy_id_array: if i in self.__dict__: ht[i] = [j.get_couch_id() for j in self.__dict__[i]] db = Utils.get_couchdb_database() self.couch_id = db.create(ht) return self.couch_id |
'balanceIsZero': balanceSign == 0, | 'balanceIsZero': balanceSign <= 1e7, | def get(self): # Get user, group and user membership user = users.get_current_user() lang = getLanguage(self, user) group = Group.get(self.request.get("group")) groupMemberships = group.memberships userMembership = findMembershipForUser(groupMemberships, user) # Go to homepage if someone is trying to acces this group ... |
def _get_first_error(self, x12str): | def _get_first_error(self, x12str, ftype=None): | def _get_first_error(self, x12str): try: fd = StringIO(x12str, encoding='ascii') except: fd = StringIO(x12str) fd.seek(0) errors = [] err_cde = None err_str = None src = pyx12.x12file.X12Reader(fd) #src = pyx12.x12file.X12Reader(fd) for seg in src: errors.extend(src.pop_errors()) errors.extend(src.pop_errors()) src.cle... |
(err_cde, err_str) = self._get_first_error(str1) | (err_cde, err_str) = self._get_first_error(str1, '837') | def test_LX_increment_good(self): seg = None str1 = 'ISA*00* *00* *ZZ*ZZ000 *ZZ*ZZ001 *030828*1128*U*00401*000010121*0*T*:~\n' str1 += 'GS*HC*ZZ000*ZZ001*20030828*1128*17*X*004010X098A1~\n' str1 += 'ST*837*11280001~\n' str1 += 'CLM*1~\n' str1 += 'LX*1~\n' str1 += 'LX*2~\n' str1 += 'L... |
if file_out: fd_out = codecs.open(file_out, mode='w', encoding='ascii') else: fd_out = sys.stdout if len(args) > 0: file_in = args[0] | for file_in in args: | def main(): try: opts, args = getopt.getopt(sys.argv[1:], 'dhefo:') except getopt.error, msg: usage() return False debug = False eol = '' file_out = None fix = False for o, a in opts: if o == '-h': usage() return True if o == '-d': debug = True if o == '-e': eol = '\n' if o == '-f': fix = True if o == '-o': file_out = ... |
else: file_in = '-' src = pyx12.x12file.X12Reader(file_in) for seg_data in src: if fix: err_codes = [(x[1]) for x in src.pop_errors()] if seg_data.get_seg_id() == 'IEA' and '021' in err_codes: seg_data.set('IEA01', '%i' % (src.gs_count)) elif seg_data.get_seg_id() == 'GE' and '5' in err_codes: seg_data.set('GE01', '%i'... | if file_out: fd_out = codecs.open(file_out, mode='w', encoding='ascii') else: fd_out = tempfile.TemporaryFile() src = pyx12.x12file.X12Reader(file_in) for seg_data in src: if fix: err_codes = [(x[1]) for x in src.pop_errors()] if seg_data.get_seg_id() == 'IEA' and '021' in err_codes: seg_data.set('IEA01', '%i' % (src.... | def main(): try: opts, args = getopt.getopt(sys.argv[1:], 'dhefo:') except getopt.error, msg: usage() return False debug = False eol = '' file_out = None fix = False for o, a in opts: if o == '-h': usage() return True if o == '-d': debug = True if o == '-e': eol = '\n' if o == '-f': fix = True if o == '-o': file_out = ... |
self.seg_count += 1 | def _parse_segment(self, seg_data): """ Catch segment issues common to both readers and writers | |
elif seg_id != 'IEA' and seg_id != 'GE' and seg_id != 'SE': | if seg_id not in ('ISA', 'IEA', 'GS', 'GE', 'ST', 'SE'): | def _parse_segment(self, seg_data): """ Catch segment issues common to both readers and writers |
seg_data.set_value('01', '%i' % (self.lx_count) ) | seg_data.set('01', '%i' % (self.lx_count) ) | def Write(self, seg_data): """ Write the segment to the stream given current separators |
def pull_cves(self, file=None): | def pull_cves(self, file=None, email=False): | def pull_cves(self, file=None): """Pull CVE XMLs from a text stream (usually the one from cve.mitre.org) """ from mdv.sec.pullcves import split import subprocess # gzip can't handle urllib's file streams, and urllib does not # handle proxies easily cves = CVEPool(self.paths.cve_database()) if file: source = open(file) ... |
source = open(file) | if file == "-": source = sys.stdin else: source = open(file) | def pull_cves(self, file=None): """Pull CVE XMLs from a text stream (usually the one from cve.mitre.org) """ from mdv.sec.pullcves import split import subprocess # gzip can't handle urllib's file streams, and urllib does not # handle proxies easily cves = CVEPool(self.paths.cve_database()) if file: source = open(file) ... |
ret = "%(table)s_%(reftable)s_fkey" % dict( | ret = "%(table)s_%(firstcolumn)s_fkey" % dict( | def autoname(self): """Mimic the database's automatic constraint names""" ret = "%(table)s_%(reftable)s_fkey" % dict( table=self.table.name, reftable=self.reftable.name,) return ret |
reftable=self.reftable.name,) | firstcolumn=self.columns[0],) | def autoname(self): """Mimic the database's automatic constraint names""" ret = "%(table)s_%(reftable)s_fkey" % dict( table=self.table.name, reftable=self.reftable.name,) return ret |
raise exceptions.InvalidScriptError(path + ': %s' % str(e)) | raise InvalidScriptError(path + ': %s' % str(e)) | def verify_module(cls, path): """Ensure path is a valid script :param path: Script location :type path: string :raises: :exc:`InvalidScriptError <migrate.exceptions.InvalidScriptError>` :returns: Python module """ # Try to import and get the upgrade() func module = import_path(path) try: assert callable(module.upgrade... |
raise exceptions.ScriptError("%d is not a valid step" % step) | raise ScriptError("%d is not a valid step" % step) | def run(self, engine, step): """Core method of Script file. Exectues :func:`update` or :func:`downgrade` functions |
" parameter (since version > 0.5.4)", exceptions.MigrateDeprecationWarning) | " parameter (since version > 0.5.4)", MigrateDeprecationWarning) | def run(self, engine, step): """Core method of Script file. Exectues :func:`update` or :func:`downgrade` functions |
self.table = k.pop('table', None) or col.table | self.table = k.pop('table', None) if self.table is None: self.table = col.table | def compare_1_column(self, col, *p, **k): """Compares one Column object""" self.table = k.pop('table', None) or col.table self.result_column = col if len(p): k = self._extract_parameters(p, k, self.result_column) return k |
self.table = k.pop('table', None) or old_col.table or new_col.table | self.table = k.pop('table', None) if self.table is None: self.table = old_col.table if self.table is None: new_col.table | def compare_2_columns(self, old_col, new_col, *p, **k): """Compares two Column objects""" self.process_column(new_col) self.table = k.pop('table', None) or old_col.table or new_col.table self.result_column = old_col |
if self.table and self.alter_metadata: | if self.table is not None and self.alter_metadata: | def apply_diffs(self, diffs): """Populate dict and column object with new values""" self.diffs = diffs for key in self.diff_keys: if key in diffs: setattr(self.result_column, key, diffs[key]) |
if table and not self.table: | if table is not None and self.table is None: | def add_to_table(self, table): if table and not self.table: self._set_parent(table) |
" parameter (since version > 0.5.4)", MigrateDeprecationWarning) | " parameter (since version > 0.5.4)", exceptions.MigrateDeprecationWarning) | def run(self, engine, step): """Core method of Script file. Exectues :func:`update` or :func:`downgrade` functions |
self.compare_columns_equal(cons.columns, self.table.primary_key) | if SQLA_06: self.compare_columns_equal(cons.columns, self.table.primary_key) else: self.compare_columns_equal(cons.columns, self.table.primary_key, ['autoincrement']) | def test_autoname_pk(self): """PrimaryKeyConstraints can guess their name if None is given""" # Don't supply a name; it should create one cons = PrimaryKeyConstraint(self.table.c.id) cons.create() self.refresh_table() if not self.url.startswith('sqlite'): # TODO: test for index for sqlite self.compare_columns_equal(con... |
self._module = sys.modules['warnings'] if module is None else module | if module is None: self._module = sys.modules['warnings'] else: self._module = module | def __init__(self, record=False, module=None): """Specify whether to record warnings and if an alternative module should be used other than sys.modules['warnings']. |
asd | def test_main_with_runpy(self): if sys.version_info[:2] == (2, 4): raise SkipTest("runpy is not part of python2.4") asd try: run_module('migrate.versioning.shell', run_name='__main__') except: pass | |
import os; print "*****************************", os.environ.get('PYTHONPATH', 'ARGH FUCK') | def load_model(dotted_name): """Import module and use module-level variable". :param dotted_name: path to model in form of string: ``some.python.module:Class`` .. versionchanged:: 0.5.4 """ if isinstance(dotted_name, basestring): if ':' not in dotted_name: # backwards compatibility warnings.warn('model should be in ... | |
self.table.c.data.alter(name='data', type=String(42)) self.refresh_table(self.table.name) self.assert_(isinstance(self.table.c.data.type, String)) self.assertEquals(self.table.c.data.type.length, 42) | def test_type(self): """Can change a column's type""" # Entire column definition given self.table.c.data.alter(name='data', type=String(42)) self.refresh_table(self.table.name) self.assert_(isinstance(self.table.c.data.type, String)) self.assertEquals(self.table.c.data.type.length, 42) | |
self.table.c.data.alter(name='data', type=String(40), server_default=DefaultClause(default)) | self.table.c.data.alter(type=String(40), server_default=DefaultClause(default)) | def test_default(self): """Can change a column's server_default value (DefaultClauses only) Only DefaultClauses are changed here: others are managed by the application / by SA """ self.assertEquals(self.table.c.data.server_default.arg, 'tluafed') |
self.table.c.data.alter(name='data', type=String(40), nullable=False) | self.table.c.data.alter(type=String(40), nullable=False) | def test_null(self): """Can change a column's null constraint""" self.assertEquals(self.table.c.data.nullable, True) |
def test_alter_metadata_deprecated(self): | def test_alter_deprecated(self): | def test_alter_metadata_deprecated(self): try: # py 2.4 compatability :-/ cw = catch_warnings(record=True) w = cw.__enter__() warnings.simplefilter("always") self.table.c.data.alter(Column('data', String(100))) |
self.table.c.data.alter(name='data', type=String(200), alter_metadata=False) | self.table.c.data.alter(type=String(200),alter_metadata=False) | def test_alter_metadata(self): """Test if alter_metadata is respected""" |
delta = self.table.c.data.alter(name='data', type=String(100)) | delta = self.table.c.data.alter(type=String(100)) | def test_alter_returns_delta(self): """Test if alter constructs return delta""" |
col2 = getattr(self.table.c, col_name) self.assertEquals(col2, col) | self.assert_(self.table.c.data.type.length, 40) col2 = self.table.c.data | def assert_numcols(num_of_expected_cols): # number of cols should be correct in table object and in database self.refresh_table(self.table_name) result = len(self.table.c) self.assertEquals(result, num_of_expected_cols), if col_k.get('primary_key', None): # new primary key: check its length too result = len(self.table... |
model_module = 'test.fixture.models:meta_rundiffs' old_model_module = 'test.fixture.models:meta_old_rundiffs' | model_module = 'tests.fixture.models:meta_rundiffs' old_model_module = 'tests.fixture.models:meta_old_rundiffs' | def test_rundiffs_in_shell(self): # This is a variant of the test_schemadiff tests but run through the shell level. # These shell tests are hard to debug (since they keep forking processes), so they shouldn't replace the lower-level tests. repos_name = 'repos_name' repos_path = self.tmp() script_path = self.tmp_py() mo... |
argv = argv or list(sys.argv[1:]) | if argv is not None: argv = argv else: argv = list(sys.argv[1:]) | def main(argv=None, **kwargs): """Shell interface to :mod:`migrate.versioning.api`. kwargs are default options that can be overriden with passing --some_option as command line option :param disable_logging: Let migrate configure logging :type disable_logging: bool """ argv = argv or list(sys.argv[1:]) commands = list... |
if isinstance(repository, str): | if isinstance(repository, basestring): | def __init__(self, engine, repository): if isinstance(repository, str): repository = Repository(repository) self.engine = engine self.repository = repository self.meta = MetaData(engine) self.load() |
raise ParseError | raise exception.ParseError | def processInputs(self): """take the converted request and make useful args of it.""" json = zope.component.getUtility(IJSONReader) stream = self._body_instream input = [] incoming = stream.read(1000) while incoming: input.append(incoming) incoming = stream.read(1000) input = ''.join(input) # ensure unicode if not isin... |
else: self._server_rpc_base = WaveService.SANDBOX_RPC_URL | def __init__(self, use_sandbox=False, server_rpc_base=None, consumer_key='anonymous', consumer_secret='anonymous', http_post=None): """Initializes a service that can perform the various OAuth steps. | |
self.test_doc.SetTextInRange(document.Range(0, 2), text) | self.test_doc.SetTextInRange(document.Range(0, 3), text) | def testSetTextInRange(self): text = 'abc' self.test_doc.SetTextInRange(document.Range(0, 2), text) self.assertEquals('abc456', self.test_doc.GetText()) self.test_doc.SetTextInRange(document.Range(2, 2), text) self.assertEquals('ababc456', self.test_doc.GetText()) |
self.test_doc.SetTextInRange(document.Range(2, 2), text) | self.test_doc.SetTextInRange(document.Range(2, 3), text) | def testSetTextInRange(self): text = 'abc' self.test_doc.SetTextInRange(document.Range(0, 2), text) self.assertEquals('abc456', self.test_doc.GetText()) self.test_doc.SetTextInRange(document.Range(2, 2), text) self.assertEquals('ababc456', self.test_doc.GetText()) |
self.assertEquals('3456', self.test_doc.GetText()) self.test_doc.DeleteRange(document.Range(0, 0)) | def testDeleteRange(self): self.test_doc.DeleteRange(document.Range(0, 1)) self.assertEquals('3456', self.test_doc.GetText()) self.test_doc.DeleteRange(document.Range(0, 0)) self.assertEquals('456', self.test_doc.GetText()) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.