bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
def MakeTestSuite(): # This is apparently needed on some systems to make sure that the tests # work even if a previous version is already installed. if 'google' in sys.modules: del sys.modules['google'] generate_proto("../src/google/protobuf/unittest.proto") generate_proto("../src/google/protobuf/unittest_custom_options.proto") generate_proto("../src/google/protobuf/unittest_import.proto") generate_proto("../src/google/protobuf/unittest_mset.proto") generate_proto("../src/google/protobuf/unittest_no_generic_services.proto") generate_proto("google/protobuf/internal/more_extensions.proto") generate_proto("google/protobuf/internal/more_messages.proto") import unittest import google.protobuf.internal.generator_test as generator_test import google.protobuf.internal.descriptor_test as descriptor_test import google.protobuf.internal.reflection_test as reflection_test import google.protobuf.internal.service_reflection_test \ as service_reflection_test import google.protobuf.internal.text_format_test as text_format_test import google.protobuf.internal.wire_format_test as wire_format_test loader = unittest.defaultTestLoader suite = unittest.TestSuite() for test in [ generator_test, descriptor_test, reflection_test, service_reflection_test, text_format_test, wire_format_test ]: suite.addTest(loader.loadTestsFromModule(test)) return suite
def MakeTestSuite(): # This is apparently needed on some systems to make sure that the tests # work even if a previous version is already installed. if 'google' in sys.modules: del sys.modules['google'] generate_proto("../src/google/protobuf/unittest.proto") generate_proto("../src/google/protobuf/unittest_custom_options.proto") generate_proto("../src/google/protobuf/unittest_import.proto") generate_proto("../src/google/protobuf/unittest_mset.proto") generate_proto("../src/google/protobuf/unittest_no_generic_services.proto") generate_proto("google/protobuf/internal/more_extensions.proto") generate_proto("google/protobuf/internal/more_messages.proto") import unittest import google.protobuf.internal.generator_test as generator_test import google.protobuf.internal.descriptor_test as descriptor_test import google.protobuf.internal.reflection_test as reflection_test import google.protobuf.internal.service_reflection_test \ as service_reflection_test import google.protobuf.internal.text_format_test as text_format_test import google.protobuf.internal.wire_format_test as wire_format_test loader = unittest.defaultTestLoader suite = unittest.TestSuite() for test in [ generator_test, descriptor_test, reflection_test, service_reflection_test, text_format_test, wire_format_test ]: suite.addTest(loader.loadTestsFromModule(test)) return suite
477,600
def _MergeField(tokenizer, message): """Merges a single protocol message field into a message. Args: tokenizer: A tokenizer to parse the field name and values. message: A protocol message to record the data. Raises: ParseError: In case of ASCII parsing problems. """ message_descriptor = message.DESCRIPTOR if tokenizer.TryConsume('['): name = [tokenizer.ConsumeIdentifier()] while tokenizer.TryConsume('.'): name.append(tokenizer.ConsumeIdentifier()) name = '.'.join(name) if not message_descriptor.is_extendable: raise tokenizer.ParseErrorPreviousToken( 'Message type "%s" does not have extensions.' % message_descriptor.full_name) field = message.Extensions._FindExtensionByName(name) if not field: raise tokenizer.ParseErrorPreviousToken( 'Extension "%s" not registered.' % name) elif message_descriptor != field.containing_type: raise tokenizer.ParseErrorPreviousToken( 'Extension "%s" does not extend message type "%s".' % ( name, message_descriptor.full_name)) tokenizer.Consume(']') else: name = tokenizer.ConsumeIdentifier() field = message_descriptor.fields_by_name.get(name, None) # Group names are expected to be capitalized as they appear in the # .proto file, which actually matches their type names, not their field # names. if not field: field = message_descriptor.fields_by_name.get(name.lower(), None) if field and field.type != descriptor.FieldDescriptor.TYPE_GROUP: field = None if (field and field.type == descriptor.FieldDescriptor.TYPE_GROUP and field.message_type.name != name): field = None if not field: raise tokenizer.ParseErrorPreviousToken( 'Message type "%s" has no field named "%s".' % ( message_descriptor.full_name, name)) if field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_MESSAGE: tokenizer.TryConsume(':') if tokenizer.TryConsume('<'): end_token = '>' else: tokenizer.Consume('{') end_token = '}' if field.label == descriptor.FieldDescriptor.LABEL_REPEATED: if field.is_extension: sub_message = message.Extensions[field].add() else: sub_message = getattr(message, field.name).add() else: if field.is_extension: sub_message = message.Extensions[field] else: sub_message = getattr(message, field.name) sub_message.SetInParent() while not tokenizer.TryConsume(end_token): if tokenizer.AtEnd(): raise tokenizer.ParseErrorPreviousToken('Expected "%s".' % (end_token)) _MergeField(tokenizer, sub_message) else: _MergeScalarField(tokenizer, message, field)
def _MergeField(tokenizer, message): """Merges a single protocol message field into a message. Args: tokenizer: A tokenizer to parse the field name and values. message: A protocol message to record the data. Raises: ParseError: In case of ASCII parsing problems. """ message_descriptor = message.DESCRIPTOR if tokenizer.TryConsume('['): name = [tokenizer.ConsumeIdentifier()] while tokenizer.TryConsume('.'): name.append(tokenizer.ConsumeIdentifier()) name = '.'.join(name) if not message_descriptor.is_extendable: raise tokenizer.ParseErrorPreviousToken( 'Message type "%s" does not have extensions.' % message_descriptor.full_name) field = message.Extensions._FindExtensionByName(name) if not field: raise tokenizer.ParseErrorPreviousToken( 'Extension "%s" not registered.' % name) elif message_descriptor != field.containing_type: raise tokenizer.ParseErrorPreviousToken( 'Extension "%s" does not extend message type "%s".' % ( name, message_descriptor.full_name)) tokenizer.Consume(']') else: name = tokenizer.ConsumeIdentifier() field = message_descriptor.fields_by_name.get(name, None) # Group names are expected to be capitalized as they appear in the # .proto file, which actually matches their type names, not their field # names. if not field: field = message_descriptor.fields_by_name.get(name.lower(), None) if field and field.type != descriptor.FieldDescriptor.TYPE_GROUP: field = None if (field and field.type == descriptor.FieldDescriptor.TYPE_GROUP and field.message_type.name != name): field = None if not field: raise tokenizer.ParseErrorPreviousToken( 'Message type "%s" has no field named "%s".' % ( message_descriptor.full_name, name)) if field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_MESSAGE: tokenizer.TryConsume(':') if tokenizer.TryConsume('<'): end_token = '>' else: tokenizer.Consume('{') end_token = '}' if field.label == descriptor.FieldDescriptor.LABEL_REPEATED: if field.is_extension: sub_message = message.Extensions[field].add() else: sub_message = getattr(message, field.name).add() else: if field.is_extension: sub_message = message.Extensions[field] else: sub_message = getattr(message, field.name) sub_message.SetInParent() while not tokenizer.TryConsume(end_token): if tokenizer.AtEnd(): raise tokenizer.ParseErrorPreviousToken('Expected "%s".' % (end_token)) _MergeField(tokenizer, sub_message) else: _MergeScalarField(tokenizer, message, field)
477,601
def __init__(self, path): self.paths = self.Paths(path) self.name = basename(path) self.link = os.readlink(self.paths.link) if not isdir(self.link): raise Error("stock link to non-directory `%s'" % stock.link)
def __init__(self, path): self.paths = self.Paths(path) self.name = basename(path) self.link = os.readlink(self.paths.link) if not isdir(self.link): raise Error("stock link to non-directory `%s'" % stock.link)
477,602
def _read_versions(self): source_versions = {} for dpath, dnames, fnames in os.walk(self.paths.source_versions): relative_path = make_relative(self.paths.source_versions, dpath) for fname in fnames: fpath = join(dpath, fname) versions = [ line.strip() for line in file(fpath).readlines() if line.strip() ] source_versions[join(relative_path, fname)] = versions
def _init_read_versions(self): source_versions = {} for dpath, dnames, fnames in os.walk(self.paths.source_versions): relative_path = make_relative(self.paths.source_versions, dpath) for fname in fnames: fpath = join(dpath, fname) versions = [ line.strip() for line in file(fpath).readlines() if line.strip() ] source_versions[join(relative_path, fname)] = versions
477,603
def _get_workdir(self): """Return an initialized workdir path.
def _init_get_workdir(self): """Return an initialized workdir path.
477,604
def __init__(self, path, pkgcache): self.paths = StockPaths(path) self.name = basename(path) self.branch = None if "#" in self.name: self.branch = self.name.split("#")[1]
def __init__(self, path, pkgcache): self.paths = StockPaths(path) self.name = basename(path) self.branch = None if "#" in self.name: self.branch = self.name.split("#")[1]
477,605
def _sync(self): """synchronise pool with registered stocks""" for binary in self.stocks.get_binaries(): if self.pkgcache.exists(basename(binary)): continue
def _sync(self): """synchronise pool with registered stocks""" for binary in self.stocks.get_binaries(): if self.pkgcache.exists(basename(binary)): continue
477,606
def exists(self, package): """Check if package exists in pool -> Returns bool""" if self.pkgcache.exists(package): return True
def exists(self, package): """Check if package exists in pool -> Returns bool""" if self.pkgcache.exists(package): return True
477,607
def _register(self, filename): name, version = self._parse_filename(filename) self.filenames[(name, version)] = filename self.packagelist.add(name)
def _register(self, filename): name, version = self._parse_filename(filename) self.filenames[(name, version)] = filename self.packagelist.add(name)
477,608
def _unregister(self, name, version): del self.filenames[(name, version)] self.packagelist.remove(name)
def _unregister(self, name, version): del self.filenames[(name, version)] self.namerefs[name] -= 1 if not self.namerefs[name]: del self.namerefs[name]
477,609
def __init__(self, path): self.path = path
def __init__(self, path): self.path = path
477,610
def exists(self, name, version=None): """Returns True if package exists in cache.
def exists(self, name, version=None): """Returns True if package exists in cache.
477,611
def list(self, all_versions=False): """List packages in pool -> list of (name, version) tuples.
def list(self, all_versions=False): """List packages in pool -> list of (name, version) tuples.
477,612
def get_binaries(self): """Recursively scan stocks for binaries -> list of filename"""
def get_binaries(self): """Recursively scan stocks for binaries -> list of filename"""
477,613
def getnum(self): str = self.str i = 0 for c in str: if c not in '0123456789': break i += 1
def def _lexcmp(a, b): i = 0 while True: if len(a) == len(b): if i == len(a): return 0 else: if i == len(a): return -1 if i == len(b): return 1 if a[i].isalpha(): if not b[i].isalpha(): return -1 if b[i].isalpha(): if not a[i].isalpha(): return 1 val = cmp(a[i], b[i]) if val != 0: return val i += 1 getnum(self): def _lexcmp(a, b): i = 0 while True: if len(a) == len(b): if i == len(a): return 0 else: if i == len(a): return -1 if i == len(b): return 1 if a[i].isalpha(): if not b[i].isalpha(): return -1 if b[i].isalpha(): if not a[i].isalpha(): return 1 val = cmp(a[i], b[i]) if val != 0: return val i += 1 str def _lexcmp(a, b): i = 0 while True: if len(a) == len(b): if i == len(a): return 0 else: if i == len(a): return -1 if i == len(b): return 1 if a[i].isalpha(): if not b[i].isalpha(): return -1 if b[i].isalpha(): if not a[i].isalpha(): return 1 val = cmp(a[i], b[i]) if val != 0: return val i += 1 = def _lexcmp(a, b): i = 0 while True: if len(a) == len(b): if i == len(a): return 0 else: if i == len(a): return -1 if i == len(b): return 1 if a[i].isalpha(): if not b[i].isalpha(): return -1 if b[i].isalpha(): if not a[i].isalpha(): return 1 val = cmp(a[i], b[i]) if val != 0: return val i += 1 self.str def _lexcmp(a, b): i = 0 while True: if len(a) == len(b): if i == len(a): return 0 else: if i == len(a): return -1 if i == len(b): return 1 if a[i].isalpha(): if not b[i].isalpha(): return -1 if b[i].isalpha(): if not a[i].isalpha(): return 1 val = cmp(a[i], b[i]) if val != 0: return val i += 1 i def _lexcmp(a, b): i = 0 while True: if len(a) == len(b): if i == len(a): return 0 else: if i == len(a): return -1 if i == len(b): return 1 if a[i].isalpha(): if not b[i].isalpha(): return -1 if b[i].isalpha(): if not a[i].isalpha(): return 1 val = cmp(a[i], b[i]) if val != 0: return val i += 1 = def _lexcmp(a, b): i = 0 while True: if len(a) == len(b): if i == len(a): return 0 else: if i == len(a): return -1 if i == len(b): return 1 if a[i].isalpha(): if not b[i].isalpha(): return -1 if b[i].isalpha(): if not a[i].isalpha(): return 1 val = cmp(a[i], b[i]) if val != 0: return val i += 1 0 def _lexcmp(a, b): i = 0 while True: if len(a) == len(b): if i == len(a): return 0 else: if i == len(a): return -1 if i == len(b): return 1 if a[i].isalpha(): if not b[i].isalpha(): return -1 if b[i].isalpha(): if not a[i].isalpha(): return 1 val = cmp(a[i], b[i]) if val != 0: return val i += 1 for def _lexcmp(a, b): i = 0 while True: if len(a) == len(b): if i == len(a): return 0 else: if i == len(a): return -1 if i == len(b): return 1 if a[i].isalpha(): if not b[i].isalpha(): return -1 if b[i].isalpha(): if not a[i].isalpha(): return 1 val = cmp(a[i], b[i]) if val != 0: return val i += 1 c def _lexcmp(a, b): i = 0 while True: if len(a) == len(b): if i == len(a): return 0 else: if i == len(a): return -1 if i == len(b): return 1 if a[i].isalpha(): if not b[i].isalpha(): return -1 if b[i].isalpha(): if not a[i].isalpha(): return 1 val = cmp(a[i], b[i]) if val != 0: return val i += 1 in def _lexcmp(a, b): i = 0 while True: if len(a) == len(b): if i == len(a): return 0 else: if i == len(a): return -1 if i == len(b): return 1 if a[i].isalpha(): if not b[i].isalpha(): return -1 if b[i].isalpha(): if not a[i].isalpha(): return 1 val = cmp(a[i], b[i]) if val != 0: return val i += 1 str: def _lexcmp(a, b): i = 0 while True: if len(a) == len(b): if i == len(a): return 0 else: if i == len(a): return -1 if i == len(b): return 1 if a[i].isalpha(): if not b[i].isalpha(): return -1 if b[i].isalpha(): if not a[i].isalpha(): return 1 val = cmp(a[i], b[i]) if val != 0: return val i += 1 if def _lexcmp(a, b): i = 0 while True: if len(a) == len(b): if i == len(a): return 0 else: if i == len(a): return -1 if i == len(b): return 1 if a[i].isalpha(): if not b[i].isalpha(): return -1 if b[i].isalpha(): if not a[i].isalpha(): return 1 val = cmp(a[i], b[i]) if val != 0: return val i += 1 c def _lexcmp(a, b): i = 0 while True: if len(a) == len(b): if i == len(a): return 0 else: if i == len(a): return -1 if i == len(b): return 1 if a[i].isalpha(): if not b[i].isalpha(): return -1 if b[i].isalpha(): if not a[i].isalpha(): return 1 val = cmp(a[i], b[i]) if val != 0: return val i += 1 not def _lexcmp(a, b): i = 0 while True: if len(a) == len(b): if i == len(a): return 0 else: if i == len(a): return -1 if i == len(b): return 1 if a[i].isalpha(): if not b[i].isalpha(): return -1 if b[i].isalpha(): if not a[i].isalpha(): return 1 val = cmp(a[i], b[i]) if val != 0: return val i += 1 in def _lexcmp(a, b): i = 0 while True: if len(a) == len(b): if i == len(a): return 0 else: if i == len(a): return -1 if i == len(b): return 1 if a[i].isalpha(): if not b[i].isalpha(): return -1 if b[i].isalpha(): if not a[i].isalpha(): return 1 val = cmp(a[i], b[i]) if val != 0: return val i += 1 '0123456789': def _lexcmp(a, b): i = 0 while True: if len(a) == len(b): if i == len(a): return 0 else: if i == len(a): return -1 if i == len(b): return 1 if a[i].isalpha(): if not b[i].isalpha(): return -1 if b[i].isalpha(): if not a[i].isalpha(): return 1 val = cmp(a[i], b[i]) if val != 0: return val i += 1 break def _lexcmp(a, b): i = 0 while True: if len(a) == len(b): if i == len(a): return 0 else: if i == len(a): return -1 if i == len(b): return 1 if a[i].isalpha(): if not b[i].isalpha(): return -1 if b[i].isalpha(): if not a[i].isalpha(): return 1 val = cmp(a[i], b[i]) if val != 0: return val i += 1 i def _lexcmp(a, b): i = 0 while True: if len(a) == len(b): if i == len(a): return 0 else: if i == len(a): return -1 if i == len(b): return 1 if a[i].isalpha(): if not b[i].isalpha(): return -1 if b[i].isalpha(): if not a[i].isalpha(): return 1 val = cmp(a[i], b[i]) if val != 0: return val i += 1 += def _lexcmp(a, b): i = 0 while True: if len(a) == len(b): if i == len(a): return 0 else: if i == len(a): return -1 if i == len(b): return 1 if a[i].isalpha(): if not b[i].isalpha(): return -1 if b[i].isalpha(): if not a[i].isalpha(): return 1 val = cmp(a[i], b[i]) if val != 0: return val i += 1 1
477,614
def _compare(s1, s2): if s1 == s2: return 0 p1 = VersionParser(s1) p2 = VersionParser(s2) while True: l1 = p1.getlex() l2 = p2.getlex() val = cmp(l1, l2) if val != 0: return val n1 = p1.getnum() n2 = p2.getnum() val = cmp(n1, n2) if val != 0: return val if p1.str == p2.str: return 0
def _compare(s1, s2): if s1 == s2: return 0 p1 = VersionParser(s1) p2 = VersionParser(s2) while True: l1 = p1.getlex() l2 = p2.getlex() val = _lexcmp(l1, l2) if val != 0: return val n1 = p1.getnum() n2 = p2.getnum() val = cmp(n1, n2) if val != 0: return val if p1.str == p2.str: return 0
477,615
def _compare_flat(s1, s2): if s1 == s2: return 0 while True: # parse lexical components i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val # if lexical component is equal parse numeric component i = 0 for c in s1: if c not in '0123456789': break i += 1 if i: n1 = int(s1[:i]) s1 = s1[i:] else: n1 = 0 i = 0 for c in s2: if c not in '0123456789': break i += 1 if i: n2 = int(s2[:i]) s2 = s2[i:] else: n2 = 0 val = cmp(n1, n2) if val != 0: return val if s1 == s2: return 0
def _compare_flat(s1, s2): if s1 == s2: return 0 while True: # parse lexical components i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = _lexcmp(l1, l2) if val != 0: return val # if lexical component is equal parse numeric component i = 0 for c in s1: if c not in '0123456789': break i += 1 if i: n1 = int(s1[:i]) s1 = s1[i:] else: n1 = 0 i = 0 for c in s2: if c not in '0123456789': break i += 1 if i: n2 = int(s2[:i]) s2 = s2[i:] else: n2 = 0 val = cmp(n1, n2) if val != 0: return val if s1 == s2: return 0
477,616
def __init__(self, path, recursed_paths=[]): StockBase.__init__(self, path) if self.link in recursed_paths: raise CircularDependency("circular dependency detected `%s' is in recursed paths %s" % (self.link, recursed_paths))
def __init__(self, path, recursed_paths=[]): StockBase.__init__(self, path) if self.link in recursed_paths: raise CircularDependency("circular dependency detected `%s' is in recursed paths %s" % (self.link, recursed_paths))
477,617
def init_create(cls, path, bare=False, verbose=False): if not lexists(path): os.mkdir(path)
def init_create(cls, path, bare=False, verbose=False): if not lexists(path): os.mkdir(path)
477,618
def _parse_stock(stock): try: dir, branch = stock.split("#", 1) except ValueError: dir = stock branch = None
def _parse_stock(stock): try: dir, branch = stock.split("#", 1) except ValueError: dir = stock branch = None
477,619
def unregister(self, stock): dir, branch = self._parse_stock(stock) stock_name = basename(dir) if branch: stock_name += "#" + branch if not self.stocks.has_key(stock_name) or \ self.stocks[stock_name].link != realpath(dir): raise Error("no matches for unregister")
def unregister(self, stock): dir, branch = self._parse_stock(stock) stock_name = basename(dir) if branch: stock_name += "#" + branch matches = [ stock for stock in self.stocks.values() if stock.link == dir and (not branch or stock.branch == branch) ] if not matches: raise Error("no matches for unregister")
477,620
def unregister(self, stock): dir, branch = self._parse_stock(stock) stock_name = basename(dir) if branch: stock_name += "#" + branch if not self.stocks.has_key(stock_name) or \ self.stocks[stock_name].link != realpath(dir): raise Error("no matches for unregister")
def unregister(self, stock): dir, branch = self._parse_stock(stock) stock_name = basename(dir) if branch: stock_name += "#" + branch if not self.stocks.has_key(stock_name) or \ self.stocks[stock_name].link != realpath(dir): raise Error("no matches for unregister")
477,621
def getpath_cached(p, package): """get path of cached package, whether in the pool or in a subpool""" path = p.pkgcache.getpath(package) if path: return path for subpool in p.subpools: path = getpath_cached(subpool, package) if path: return path return None
def pkgcache_list_versions(pool, name): versions = [ pkgcache_version for pkgcache_name, pkgcache_version in pool.pkgcache.list() if pkgcache_name == name ] for subpool in pool.subpools: versions += pkgcache_list_versions(subpool, name) return versions def pkgcache_getpath_newest(pool, name): versions = pkgcache_list_versions(pool, name) if not versions: return None versions.sort(debversion.compare) version_newest = versions[-1] package = pool.fmt_package_id(name, version_newest) return pool.getpath_deb(package, build=False) def binary2source(pool, package): """translate package from binary to source""" name, version = pool.parse_package_id(package) if version: path = pool.getpath_deb(package, build=False) if not path: return None source_name = extract_source_name(path) if not source_name: return package return pool.fmt_package_id(source_name, version) path = pkgcache_getpath_newest(pool, name) if not path: return None source_name = extract_source_name(path) if not source_name: return name return source_name def getpath_build_log(package): try: pool = Pool() except Pool.Error, e: fatal(e) path = pool.getpath_build_log(package) if path: return path for subpool in p.subpools: path = getpath_cached(subpool, package) if path: return path return None
477,622
def getpath_cached(p, package): """get path of cached package, whether in the pool or in a subpool""" path = p.pkgcache.getpath(package) if path: return path for subpool in p.subpools: path = getpath_cached(subpool, package) if path: return path return None
def getpath_cached(p, package): """get path of cached package, whether in the pool or in a subpool""" path = p.pkgcache.getpath(package) if path: return path source_package = binary2source(pool, package) if source_package: path = pool.getpath_build_log(source_package) return None
477,623
def getpath_cached(p, package): """get path of cached package, whether in the pool or in a subpool""" path = p.pkgcache.getpath(package) if path: return path for subpool in p.subpools: path = getpath_cached(subpool, package) if path: return path return None
def getpath_cached(p, package): """get path of cached package, whether in the pool or in a subpool""" path = p.pkgcache.getpath(package) if path: return path for subpool in p.subpools: path = getpath_cached(subpool, package) if path: return path return None
477,624
def main(): args = sys.argv[1:] if not args: usage() package = args[0] try: p = pool.Pool() except pool.Error, e: fatal(e) source_package = package deb = getpath_cached(p, package) if deb: source_name = extract_source_name(deb) if source_name: source_package = source_name if '=' in package: source_package += "=" + package.split("=", 1)[1] path = p.getpath_build_log(source_package) if not path: fatal("no build log for `%s' (%s)" % (package, source_package)) for line in file(path).readlines(): print line,
def main(): args = sys.argv[1:] if not args: usage() package = args[0] path = getpath_build_log(package) source_package = package deb = getpath_cached(p, package) if deb: source_name = extract_source_name(deb) if source_name: source_package = source_name if '=' in package: source_package += "=" + package.split("=", 1)[1] path = p.getpath_build_log(source_package) if not path: fatal("no build log for `%s' (%s)" % (package, source_package)) for line in file(path).readlines(): print line,
477,625
def main(): args = sys.argv[1:] if not args: usage() package = args[0] try: p = pool.Pool() except pool.Error, e: fatal(e) source_package = package deb = getpath_cached(p, package) if deb: source_name = extract_source_name(deb) if source_name: source_package = source_name if '=' in package: source_package += "=" + package.split("=", 1)[1] path = p.getpath_build_log(source_package) if not path: fatal("no build log for `%s' (%s)" % (package, source_package)) for line in file(path).readlines(): print line,
def main(): args = sys.argv[1:] if not args: usage() package = args[0] try: p = pool.Pool() except pool.Error, e: fatal(e) for line in file(path).readlines(): print line,
477,626
def _compare(s1, s2): if s1 == s2: return 0 p1 = VersionParser(s1) p2 = VersionParser(s2) while True: l1 = p1.getlex() l2 = p2.getlex() val = cmp(l1, l2) if val != 0: return val n1 = p1.getnum() n2 = p2.getnum() val = cmp(n1, n2) if val != 0: return val
def _compare(s1, s2): if s1 == s2: return 0 p1 = VersionParser(s1) p2 = VersionParser(s2) while True: l1 = p1.getlex() l2 = p2.getlex() val = cmp(l1, l2) if val != 0: return val
477,627
def parse(v): if ':' in v: epoch, v = v.split(':', 1) else: epoch = 0 if '-' in v: upstream_version, debian_revision = v.rsplit('-', 1) else: upstream_version = v debian_revision = '' return epoch, upstream_version, debian_revision
def parse(v): if ':' in v: epoch, v = v.split(':', 1) else: epoch = '' if '-' in v: upstream_version, debian_revision = v.rsplit('-', 1) else: upstream_version = v debian_revision = '' return epoch, upstream_version, debian_revision
477,628
def parse(v): if ':' in v: epoch, v = v.split(':', 1) else: epoch = 0 if '-' in v: upstream_version, debian_revision = v.rsplit('-', 1) else: upstream_version = v debian_revision = '' return epoch, upstream_version, debian_revision
def class VersionParser: def __init__(self, str): self.str = str def getlex(self): lex = re.match(r'(\D*)', self.str).group(1) self.str = self.str[len(lex):] return lex def getnum(self): num = re.match(r'(\d*)', self.str).group(1) self.str = self.str[len(num):] if num: return int(num) return 0 def _compare(s1, s2): if s1 == s2: return 0 p1 = VersionParser(s1) p2 = VersionParser(s2) while True: l1 = p1.getlex() l2 = p2.getlex() val = cmp(l1, l2) if val != 0: return val n1 = p1.getnum() n2 = p2.getnum() val = cmp(n1, n2) if val != 0: return val parse(v): class VersionParser: def __init__(self, str): self.str = str def getlex(self): lex = re.match(r'(\D*)', self.str).group(1) self.str = self.str[len(lex):] return lex def getnum(self): num = re.match(r'(\d*)', self.str).group(1) self.str = self.str[len(num):] if num: return int(num) return 0 def _compare(s1, s2): if s1 == s2: return 0 p1 = VersionParser(s1) p2 = VersionParser(s2) while True: l1 = p1.getlex() l2 = p2.getlex() val = cmp(l1, l2) if val != 0: return val n1 = p1.getnum() n2 = p2.getnum() val = cmp(n1, n2) if val != 0: return val if class VersionParser: def __init__(self, str): self.str = str def getlex(self): lex = re.match(r'(\D*)', self.str).group(1) self.str = self.str[len(lex):] return lex def getnum(self): num = re.match(r'(\d*)', self.str).group(1) self.str = self.str[len(num):] if num: return int(num) return 0 def _compare(s1, s2): if s1 == s2: return 0 p1 = VersionParser(s1) p2 = VersionParser(s2) while True: l1 = p1.getlex() l2 = p2.getlex() val = cmp(l1, l2) if val != 0: return val n1 = p1.getnum() n2 = p2.getnum() val = cmp(n1, n2) if val != 0: return val ':' class VersionParser: def __init__(self, str): self.str = str def getlex(self): lex = re.match(r'(\D*)', self.str).group(1) self.str = self.str[len(lex):] return lex def getnum(self): num = re.match(r'(\d*)', self.str).group(1) self.str = self.str[len(num):] if num: return int(num) return 0 def _compare(s1, s2): if s1 == s2: return 0 p1 = VersionParser(s1) p2 = VersionParser(s2) while True: l1 = p1.getlex() l2 = p2.getlex() val = cmp(l1, l2) if val != 0: return val n1 = p1.getnum() n2 = p2.getnum() val = cmp(n1, n2) if val != 0: return val in class VersionParser: def __init__(self, str): self.str = str def getlex(self): lex = re.match(r'(\D*)', self.str).group(1) self.str = self.str[len(lex):] return lex def getnum(self): num = re.match(r'(\d*)', self.str).group(1) self.str = self.str[len(num):] if num: return int(num) return 0 def _compare(s1, s2): if s1 == s2: return 0 p1 = VersionParser(s1) p2 = VersionParser(s2) while True: l1 = p1.getlex() l2 = p2.getlex() val = cmp(l1, l2) if val != 0: return val n1 = p1.getnum() n2 = p2.getnum() val = cmp(n1, n2) if val != 0: return val v: class VersionParser: def __init__(self, str): self.str = str def getlex(self): lex = re.match(r'(\D*)', self.str).group(1) self.str = self.str[len(lex):] return lex def getnum(self): num = re.match(r'(\d*)', self.str).group(1) self.str = self.str[len(num):] if num: return int(num) return 0 def _compare(s1, s2): if s1 == s2: return 0 p1 = VersionParser(s1) p2 = VersionParser(s2) while True: l1 = p1.getlex() l2 = p2.getlex() val = cmp(l1, l2) if val != 0: return val n1 = p1.getnum() n2 = p2.getnum() val = cmp(n1, n2) if val != 0: return val epoch, class VersionParser: def __init__(self, str): self.str = str def getlex(self): lex = re.match(r'(\D*)', self.str).group(1) self.str = self.str[len(lex):] return lex def getnum(self): num = re.match(r'(\d*)', self.str).group(1) self.str = self.str[len(num):] if num: return int(num) return 0 def _compare(s1, s2): if s1 == s2: return 0 p1 = VersionParser(s1) p2 = VersionParser(s2) while True: l1 = p1.getlex() l2 = p2.getlex() val = cmp(l1, l2) if val != 0: return val n1 = p1.getnum() n2 = p2.getnum() val = cmp(n1, n2) if val != 0: return val v class VersionParser: def __init__(self, str): self.str = str def getlex(self): lex = re.match(r'(\D*)', self.str).group(1) self.str = self.str[len(lex):] return lex def getnum(self): num = re.match(r'(\d*)', self.str).group(1) self.str = self.str[len(num):] if num: return int(num) return 0 def _compare(s1, s2): if s1 == s2: return 0 p1 = VersionParser(s1) p2 = VersionParser(s2) while True: l1 = p1.getlex() l2 = p2.getlex() val = cmp(l1, l2) if val != 0: return val n1 = p1.getnum() n2 = p2.getnum() val = cmp(n1, n2) if val != 0: return val = class VersionParser: def __init__(self, str): self.str = str def getlex(self): lex = re.match(r'(\D*)', self.str).group(1) self.str = self.str[len(lex):] return lex def getnum(self): num = re.match(r'(\d*)', self.str).group(1) self.str = self.str[len(num):] if num: return int(num) return 0 def _compare(s1, s2): if s1 == s2: return 0 p1 = VersionParser(s1) p2 = VersionParser(s2) while True: l1 = p1.getlex() l2 = p2.getlex() val = cmp(l1, l2) if val != 0: return val n1 = p1.getnum() n2 = p2.getnum() val = cmp(n1, n2) if val != 0: return val v.split(':', class VersionParser: def __init__(self, str): self.str = str def getlex(self): lex = re.match(r'(\D*)', self.str).group(1) self.str = self.str[len(lex):] return lex def getnum(self): num = re.match(r'(\d*)', self.str).group(1) self.str = self.str[len(num):] if num: return int(num) return 0 def _compare(s1, s2): if s1 == s2: return 0 p1 = VersionParser(s1) p2 = VersionParser(s2) while True: l1 = p1.getlex() l2 = p2.getlex() val = cmp(l1, l2) if val != 0: return val n1 = p1.getnum() n2 = p2.getnum() val = cmp(n1, n2) if val != 0: return val 1) class VersionParser: def __init__(self, str): self.str = str def getlex(self): lex = re.match(r'(\D*)', self.str).group(1) self.str = self.str[len(lex):] return lex def getnum(self): num = re.match(r'(\d*)', self.str).group(1) self.str = self.str[len(num):] if num: return int(num) return 0 def _compare(s1, s2): if s1 == s2: return 0 p1 = VersionParser(s1) p2 = VersionParser(s2) while True: l1 = p1.getlex() l2 = p2.getlex() val = cmp(l1, l2) if val != 0: return val n1 = p1.getnum() n2 = p2.getnum() val = cmp(n1, n2) if val != 0: return val else: class VersionParser: def __init__(self, str): self.str = str def getlex(self): lex = re.match(r'(\D*)', self.str).group(1) self.str = self.str[len(lex):] return lex def getnum(self): num = re.match(r'(\d*)', self.str).group(1) self.str = self.str[len(num):] if num: return int(num) return 0 def _compare(s1, s2): if s1 == s2: return 0 p1 = VersionParser(s1) p2 = VersionParser(s2) while True: l1 = p1.getlex() l2 = p2.getlex() val = cmp(l1, l2) if val != 0: return val n1 = p1.getnum() n2 = p2.getnum() val = cmp(n1, n2) if val != 0: return val epoch class VersionParser: def __init__(self, str): self.str = str def getlex(self): lex = re.match(r'(\D*)', self.str).group(1) self.str = self.str[len(lex):] return lex def getnum(self): num = re.match(r'(\d*)', self.str).group(1) self.str = self.str[len(num):] if num: return int(num) return 0 def _compare(s1, s2): if s1 == s2: return 0 p1 = VersionParser(s1) p2 = VersionParser(s2) while True: l1 = p1.getlex() l2 = p2.getlex() val = cmp(l1, l2) if val != 0: return val n1 = p1.getnum() n2 = p2.getnum() val = cmp(n1, n2) if val != 0: return val = class VersionParser: def __init__(self, str): self.str = str def getlex(self): lex = re.match(r'(\D*)', self.str).group(1) self.str = self.str[len(lex):] return lex def getnum(self): num = re.match(r'(\d*)', self.str).group(1) self.str = self.str[len(num):] if num: return int(num) return 0 def _compare(s1, s2): if s1 == s2: return 0 p1 = VersionParser(s1) p2 = VersionParser(s2) while True: l1 = p1.getlex() l2 = p2.getlex() val = cmp(l1, l2) if val != 0: return val n1 = p1.getnum() n2 = p2.getnum() val = cmp(n1, n2) if val != 0: return val 0 class VersionParser: def __init__(self, str): self.str = str def getlex(self): lex = re.match(r'(\D*)', self.str).group(1) self.str = self.str[len(lex):] return lex def getnum(self): num = re.match(r'(\d*)', self.str).group(1) self.str = self.str[len(num):] if num: return int(num) return 0 def _compare(s1, s2): if s1 == s2: return 0 p1 = VersionParser(s1) p2 = VersionParser(s2) while True: l1 = p1.getlex() l2 = p2.getlex() val = cmp(l1, l2) if val != 0: return val n1 = p1.getnum() n2 = p2.getnum() val = cmp(n1, n2) if val != 0: return val class VersionParser: def __init__(self, str): self.str = str def getlex(self): lex = re.match(r'(\D*)', self.str).group(1) self.str = self.str[len(lex):] return lex def getnum(self): num = re.match(r'(\d*)', self.str).group(1) self.str = self.str[len(num):] if num: return int(num) return 0 def _compare(s1, s2): if s1 == s2: return 0 p1 = VersionParser(s1) p2 = VersionParser(s2) while True: l1 = p1.getlex() l2 = p2.getlex() val = cmp(l1, l2) if val != 0: return val n1 = p1.getnum() n2 = p2.getnum() val = cmp(n1, n2) if val != 0: return val if class VersionParser: def __init__(self, str): self.str = str def getlex(self): lex = re.match(r'(\D*)', self.str).group(1) self.str = self.str[len(lex):] return lex def getnum(self): num = re.match(r'(\d*)', self.str).group(1) self.str = self.str[len(num):] if num: return int(num) return 0 def _compare(s1, s2): if s1 == s2: return 0 p1 = VersionParser(s1) p2 = VersionParser(s2) while True: l1 = p1.getlex() l2 = p2.getlex() val = cmp(l1, l2) if val != 0: return val n1 = p1.getnum() n2 = p2.getnum() val = cmp(n1, n2) if val != 0: return val '-' class VersionParser: def __init__(self, str): self.str = str def getlex(self): lex = re.match(r'(\D*)', self.str).group(1) self.str = self.str[len(lex):] return lex def getnum(self): num = re.match(r'(\d*)', self.str).group(1) self.str = self.str[len(num):] if num: return int(num) return 0 def _compare(s1, s2): if s1 == s2: return 0 p1 = VersionParser(s1) p2 = VersionParser(s2) while True: l1 = p1.getlex() l2 = p2.getlex() val = cmp(l1, l2) if val != 0: return val n1 = p1.getnum() n2 = p2.getnum() val = cmp(n1, n2) if val != 0: return val in class VersionParser: def __init__(self, str): self.str = str def getlex(self): lex = re.match(r'(\D*)', self.str).group(1) self.str = self.str[len(lex):] return lex def getnum(self): num = re.match(r'(\d*)', self.str).group(1) self.str = self.str[len(num):] if num: return int(num) return 0 def _compare(s1, s2): if s1 == s2: return 0 p1 = VersionParser(s1) p2 = VersionParser(s2) while True: l1 = p1.getlex() l2 = p2.getlex() val = cmp(l1, l2) if val != 0: return val n1 = p1.getnum() n2 = p2.getnum() val = cmp(n1, n2) if val != 0: return val v: class VersionParser: def __init__(self, str): self.str = str def getlex(self): lex = re.match(r'(\D*)', self.str).group(1) self.str = self.str[len(lex):] return lex def getnum(self): num = re.match(r'(\d*)', self.str).group(1) self.str = self.str[len(num):] if num: return int(num) return 0 def _compare(s1, s2): if s1 == s2: return 0 p1 = VersionParser(s1) p2 = VersionParser(s2) while True: l1 = p1.getlex() l2 = p2.getlex() val = cmp(l1, l2) if val != 0: return val n1 = p1.getnum() n2 = p2.getnum() val = cmp(n1, n2) if val != 0: return val upstream_version, class VersionParser: def __init__(self, str): self.str = str def getlex(self): lex = re.match(r'(\D*)', self.str).group(1) self.str = self.str[len(lex):] return lex def getnum(self): num = re.match(r'(\d*)', self.str).group(1) self.str = self.str[len(num):] if num: return int(num) return 0 def _compare(s1, s2): if s1 == s2: return 0 p1 = VersionParser(s1) p2 = VersionParser(s2) while True: l1 = p1.getlex() l2 = p2.getlex() val = cmp(l1, l2) if val != 0: return val n1 = p1.getnum() n2 = p2.getnum() val = cmp(n1, n2) if val != 0: return val debian_revision class VersionParser: def __init__(self, str): self.str = str def getlex(self): lex = re.match(r'(\D*)', self.str).group(1) self.str = self.str[len(lex):] return lex def getnum(self): num = re.match(r'(\d*)', self.str).group(1) self.str = self.str[len(num):] if num: return int(num) return 0 def _compare(s1, s2): if s1 == s2: return 0 p1 = VersionParser(s1) p2 = VersionParser(s2) while True: l1 = p1.getlex() l2 = p2.getlex() val = cmp(l1, l2) if val != 0: return val n1 = p1.getnum() n2 = p2.getnum() val = cmp(n1, n2) if val != 0: return val = class VersionParser: def __init__(self, str): self.str = str def getlex(self): lex = re.match(r'(\D*)', self.str).group(1) self.str = self.str[len(lex):] return lex def getnum(self): num = re.match(r'(\d*)', self.str).group(1) self.str = self.str[len(num):] if num: return int(num) return 0 def _compare(s1, s2): if s1 == s2: return 0 p1 = VersionParser(s1) p2 = VersionParser(s2) while True: l1 = p1.getlex() l2 = p2.getlex() val = cmp(l1, l2) if val != 0: return val n1 = p1.getnum() n2 = p2.getnum() val = cmp(n1, n2) if val != 0: return val v.rsplit('-', class VersionParser: def __init__(self, str): self.str = str def getlex(self): lex = re.match(r'(\D*)', self.str).group(1) self.str = self.str[len(lex):] return lex def getnum(self): num = re.match(r'(\d*)', self.str).group(1) self.str = self.str[len(num):] if num: return int(num) return 0 def _compare(s1, s2): if s1 == s2: return 0 p1 = VersionParser(s1) p2 = VersionParser(s2) while True: l1 = p1.getlex() l2 = p2.getlex() val = cmp(l1, l2) if val != 0: return val n1 = p1.getnum() n2 = p2.getnum() val = cmp(n1, n2) if val != 0: return val 1) class VersionParser: def __init__(self, str): self.str = str def getlex(self): lex = re.match(r'(\D*)', self.str).group(1) self.str = self.str[len(lex):] return lex def getnum(self): num = re.match(r'(\d*)', self.str).group(1) self.str = self.str[len(num):] if num: return int(num) return 0 def _compare(s1, s2): if s1 == s2: return 0 p1 = VersionParser(s1) p2 = VersionParser(s2) while True: l1 = p1.getlex() l2 = p2.getlex() val = cmp(l1, l2) if val != 0: return val n1 = p1.getnum() n2 = p2.getnum() val = cmp(n1, n2) if val != 0: return val else: class VersionParser: def __init__(self, str): self.str = str def getlex(self): lex = re.match(r'(\D*)', self.str).group(1) self.str = self.str[len(lex):] return lex def getnum(self): num = re.match(r'(\d*)', self.str).group(1) self.str = self.str[len(num):] if num: return int(num) return 0 def _compare(s1, s2): if s1 == s2: return 0 p1 = VersionParser(s1) p2 = VersionParser(s2) while True: l1 = p1.getlex() l2 = p2.getlex() val = cmp(l1, l2) if val != 0: return val n1 = p1.getnum() n2 = p2.getnum() val = cmp(n1, n2) if val != 0: return val upstream_version class VersionParser: def __init__(self, str): self.str = str def getlex(self): lex = re.match(r'(\D*)', self.str).group(1) self.str = self.str[len(lex):] return lex def getnum(self): num = re.match(r'(\d*)', self.str).group(1) self.str = self.str[len(num):] if num: return int(num) return 0 def _compare(s1, s2): if s1 == s2: return 0 p1 = VersionParser(s1) p2 = VersionParser(s2) while True: l1 = p1.getlex() l2 = p2.getlex() val = cmp(l1, l2) if val != 0: return val n1 = p1.getnum() n2 = p2.getnum() val = cmp(n1, n2) if val != 0: return val = class VersionParser: def __init__(self, str): self.str = str def getlex(self): lex = re.match(r'(\D*)', self.str).group(1) self.str = self.str[len(lex):] return lex def getnum(self): num = re.match(r'(\d*)', self.str).group(1) self.str = self.str[len(num):] if num: return int(num) return 0 def _compare(s1, s2): if s1 == s2: return 0 p1 = VersionParser(s1) p2 = VersionParser(s2) while True: l1 = p1.getlex() l2 = p2.getlex() val = cmp(l1, l2) if val != 0: return val n1 = p1.getnum() n2 = p2.getnum() val = cmp(n1, n2) if val != 0: return val v class VersionParser: def __init__(self, str): self.str = str def getlex(self): lex = re.match(r'(\D*)', self.str).group(1) self.str = self.str[len(lex):] return lex def getnum(self): num = re.match(r'(\d*)', self.str).group(1) self.str = self.str[len(num):] if num: return int(num) return 0 def _compare(s1, s2): if s1 == s2: return 0 p1 = VersionParser(s1) p2 = VersionParser(s2) while True: l1 = p1.getlex() l2 = p2.getlex() val = cmp(l1, l2) if val != 0: return val n1 = p1.getnum() n2 = p2.getnum() val = cmp(n1, n2) if val != 0: return val debian_revision class VersionParser: def __init__(self, str): self.str = str def getlex(self): lex = re.match(r'(\D*)', self.str).group(1) self.str = self.str[len(lex):] return lex def getnum(self): num = re.match(r'(\d*)', self.str).group(1) self.str = self.str[len(num):] if num: return int(num) return 0 def _compare(s1, s2): if s1 == s2: return 0 p1 = VersionParser(s1) p2 = VersionParser(s2) while True: l1 = p1.getlex() l2 = p2.getlex() val = cmp(l1, l2) if val != 0: return val n1 = p1.getnum() n2 = p2.getnum() val = cmp(n1, n2) if val != 0: return val = class VersionParser: def __init__(self, str): self.str = str def getlex(self): lex = re.match(r'(\D*)', self.str).group(1) self.str = self.str[len(lex):] return lex def getnum(self): num = re.match(r'(\d*)', self.str).group(1) self.str = self.str[len(num):] if num: return int(num) return 0 def _compare(s1, s2): if s1 == s2: return 0 p1 = VersionParser(s1) p2 = VersionParser(s2) while True: l1 = p1.getlex() l2 = p2.getlex() val = cmp(l1, l2) if val != 0: return val n1 = p1.getnum() n2 = p2.getnum() val = cmp(n1, n2) if val != 0: return val '' class VersionParser: def __init__(self, str): self.str = str def getlex(self): lex = re.match(r'(\D*)', self.str).group(1) self.str = self.str[len(lex):] return lex def getnum(self): num = re.match(r'(\d*)', self.str).group(1) self.str = self.str[len(num):] if num: return int(num) return 0 def _compare(s1, s2): if s1 == s2: return 0 p1 = VersionParser(s1) p2 = VersionParser(s2) while True: l1 = p1.getlex() l2 = p2.getlex() val = cmp(l1, l2) if val != 0: return val n1 = p1.getnum() n2 = p2.getnum() val = cmp(n1, n2) if val != 0: return val class VersionParser: def __init__(self, str): self.str = str def getlex(self): lex = re.match(r'(\D*)', self.str).group(1) self.str = self.str[len(lex):] return lex def getnum(self): num = re.match(r'(\d*)', self.str).group(1) self.str = self.str[len(num):] if num: return int(num) return 0 def _compare(s1, s2): if s1 == s2: return 0 p1 = VersionParser(s1) p2 = VersionParser(s2) while True: l1 = p1.getlex() l2 = p2.getlex() val = cmp(l1, l2) if val != 0: return val n1 = p1.getnum() n2 = p2.getnum() val = cmp(n1, n2) if val != 0: return val return class VersionParser: def __init__(self, str): self.str = str def getlex(self): lex = re.match(r'(\D*)', self.str).group(1) self.str = self.str[len(lex):] return lex def getnum(self): num = re.match(r'(\d*)', self.str).group(1) self.str = self.str[len(num):] if num: return int(num) return 0 def _compare(s1, s2): if s1 == s2: return 0 p1 = VersionParser(s1) p2 = VersionParser(s2) while True: l1 = p1.getlex() l2 = p2.getlex() val = cmp(l1, l2) if val != 0: return val n1 = p1.getnum() n2 = p2.getnum() val = cmp(n1, n2) if val != 0: return val epoch, class VersionParser: def __init__(self, str): self.str = str def getlex(self): lex = re.match(r'(\D*)', self.str).group(1) self.str = self.str[len(lex):] return lex def getnum(self): num = re.match(r'(\d*)', self.str).group(1) self.str = self.str[len(num):] if num: return int(num) return 0 def _compare(s1, s2): if s1 == s2: return 0 p1 = VersionParser(s1) p2 = VersionParser(s2) while True: l1 = p1.getlex() l2 = p2.getlex() val = cmp(l1, l2) if val != 0: return val n1 = p1.getnum() n2 = p2.getnum() val = cmp(n1, n2) if val != 0: return val upstream_version, class VersionParser: def __init__(self, str): self.str = str def getlex(self): lex = re.match(r'(\D*)', self.str).group(1) self.str = self.str[len(lex):] return lex def getnum(self): num = re.match(r'(\d*)', self.str).group(1) self.str = self.str[len(num):] if num: return int(num) return 0 def _compare(s1, s2): if s1 == s2: return 0 p1 = VersionParser(s1) p2 = VersionParser(s2) while True: l1 = p1.getlex() l2 = p2.getlex() val = cmp(l1, l2) if val != 0: return val n1 = p1.getnum() n2 = p2.getnum() val = cmp(n1, n2) if val != 0: return val debian_revision class VersionParser: def __init__(self, str): self.str = str def getlex(self): lex = re.match(r'(\D*)', self.str).group(1) self.str = self.str[len(lex):] return lex def getnum(self): num = re.match(r'(\d*)', self.str).group(1) self.str = self.str[len(num):] if num: return int(num) return 0 def _compare(s1, s2): if s1 == s2: return 0 p1 = VersionParser(s1) p2 = VersionParser(s2) while True: l1 = p1.getlex() l2 = p2.getlex() val = cmp(l1, l2) if val != 0: return val n1 = p1.getnum() n2 = p2.getnum() val = cmp(n1, n2) if val != 0: return val
477,629
def parse(v): if ':' in v: epoch, v = v.split(':', 1) else: epoch = '' if '-' in v: upstream_version, debian_revision = v.rsplit('-', 1) else: upstream_version = v debian_revision = '' return epoch, upstream_version, debian_revision
def parse(v): if ':' in v: epoch, v = v.split(':', 1) else: epoch = '0' if '-' in v: upstream_version, debian_revision = v.rsplit('-', 1) else: upstream_version = v debian_revision = '' return epoch, upstream_version, debian_revision
477,630
def parse(v): if ':' in v: epoch, v = v.split(':', 1) else: epoch = '' if '-' in v: upstream_version, debian_revision = v.rsplit('-', 1) else: upstream_version = v debian_revision = '' return epoch, upstream_version, debian_revision
def parse(v): if ':' in v: epoch, v = v.split(':', 1) else: epoch = '' if '-' in v: upstream_version, debian_revision = v.rsplit('-', 1) else: upstream_version = v debian_revision = '0' return epoch, upstream_version, debian_revision
477,631
def compare(a, b): """Compare a with b according to Debian versioning criteria""" a = parse(normalize(a)) b = parse(normalize(b)) for i in (0, 1, 2): val = _compare(a[i], b[i]) if val != 0: return val return 0
def compare(a, b): """Compare a with b according to Debian versioning criteria""" a = parse(a) b = parse(b) for i in (0, 1, 2): val = _compare(a[i], b[i]) if val != 0: return val return 0
477,632
def compare(a, b): """Compare a with b according to Debian versioning criteria""" a = parse(normalize(a)) b = parse(normalize(b)) for i in (0, 1, 2): val = _compare(a[i], b[i]) if val != 0: return val return 0
def compare(a, b): """Compare a with b according to Debian versioning criteria""" a = parse(normalize(a)) b = parse(normalize(b)) for i in (0, 1, 2): val = _compare_flat(a[i], b[i]) if val != 0: return val return 0
477,633
def test(): import time howmany = 1000 start = time.time() for i in xrange(howmany): compare("0-2010.10.1-d6cbb928", "0-2010.10.10-a9ee521c") end = time.time() elapsed = end - start print "%d runs in %.4f seconds (%.2f per/sec)" % (howmany, elapsed, howmany / elapsed)
def test(): import time howmany = 10000 start = time.time() for i in xrange(howmany): compare("0-2010.10.1-d6cbb928", "0-2010.10.10-a9ee521c") end = time.time() elapsed = end - start print "%d runs in %.4f seconds (%.2f per/sec)" % (howmany, elapsed, howmany / elapsed)
477,634
def resolve(self, unresolved): """Resolve a list of unresolved packages. If unresolved is a single unresolved package, return a single resolved package. If unresolved is a tuple or list of unresolved packages, return a list of resolved packages"""
def resolve(self, unresolved): """Resolve a list of unresolved packages. If unresolved is a single unresolved package, return a single resolved package. If unresolved is a tuple or list of unresolved packages, return a list of resolved packages"""
477,635
def _compare(s1, s2): if s1 == s2: return 0 p1 = VersionParser(s1) p2 = VersionParser(s2) while True: n1 = p1.getnum() n2 = p2.getnum() val = cmp(n1, n2) if val != 0: return val l1 = p1.getlex() l2 = p2.getlex() val = cmp(l1, l2) if val != 0: return val if p1.str == p2.str: return 0
def _compare(s1, s2): if s1 == s2: return 0 p1 = VersionParser(s1) p2 = VersionParser(s2) while True: n1 = p1.getnum() n2 = p2.getnum() val = cmp(n1, n2) if val != 0: return val if p1.str == p2.str: return 0
477,636
def _compare_flat(s1, s2): if s1 == s2: return 0 while True: # parse numeric component for comparison i = 0 for c in s1: if c not in '0123456789': break i += 1 if i: n1 = int(s1[:i]) s1 = s1[i:] else: n1 = 0 i = 0 for c in s2: if c not in '0123456789': break i += 1 if i: n2 = int(s2[:i]) s2 = s2[i:] else: n2 = 0 val = cmp(n1, n2) if val != 0: return val # if numeric components equal, parse lexical components i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val if s1 == s2: return 0
def i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val _compare_flat(s1, i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val s2): i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val if i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val s1 i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val == i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val s2: i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val return i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val 0 i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val while i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val True: i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val # i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val parse i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val numeric i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val component i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val for i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val comparison i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val i i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val = i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val 0 i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val for i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val c i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val in i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val s1: i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val if i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val c i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val not i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val in i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val '0123456789': i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val break i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val i i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val += i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val 1 i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val if i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val i: i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val n1 i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val = i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val int(s1[:i]) i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val s1 i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val = i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val s1[i:] i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val else: i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val n1 i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val = i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val 0 i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val i i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val = i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val 0 i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val for i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val c i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val in i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val s2: i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val if i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val c i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val not i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val in i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val '0123456789': i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val break i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val i i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val += i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val 1 i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val if i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val i: i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val n2 i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val = i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val int(s2[:i]) i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val s2 i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val = i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val s2[i:] i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val else: i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val n2 i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val = i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val 0 i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val val i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val = i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val cmp(n1, i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val n2) i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val if i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val val i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val != i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val 0: i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val return i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val val i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val # i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val if i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val numeric i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val components i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val equal, i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val parse i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val lexical i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val components i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val i i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val = i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val 0 i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val for i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val c i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val in i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val s1: i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val if i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val c i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val in i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val '0123456789': i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val break i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val i i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val += i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val 1 i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val if i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val i: i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val l1 i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val = i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val s1[:i] i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val s1 i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val = i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val s1[i:] i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val else: i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val l1 i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val = i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val '' i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val i i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val = i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val 0 i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val for i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val c i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val in i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val s2: i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val if i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val c i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val in i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val '0123456789': i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val break i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val i i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val += i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val 1 i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val if i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val i: i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val l2 i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val = i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val s2[:i] i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val s2 i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val = i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val s2[i:] i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val else: i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val l2 i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val = i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val '' i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val val i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val = i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val cmp(l1, i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val l2) i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val if i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val val i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val != i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val 0: i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val return i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val val i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val if i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val s1 i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val == i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val s2: i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val return i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val 0 i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val
477,637
def _compare_flat(s1, s2): if s1 == s2: return 0 while True: # parse numeric component for comparison i = 0 for c in s1: if c not in '0123456789': break i += 1 if i: n1 = int(s1[:i]) s1 = s1[i:] else: n1 = 0 i = 0 for c in s2: if c not in '0123456789': break i += 1 if i: n2 = int(s2[:i]) s2 = s2[i:] else: n2 = 0 val = cmp(n1, n2) if val != 0: return val # if numeric components equal, parse lexical components i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val if s1 == s2: return 0
def _compare_flat(s1, s2): if s1 == s2: return 0 while True: # parse numeric component for comparison i = 0 for c in s1: if c not in '0123456789': break i += 1 if i: n1 = int(s1[:i]) s1 = s1[i:] else: n1 = 0 i = 0 for c in s2: if c not in '0123456789': break i += 1 if i: n2 = int(s2[:i]) s2 = s2[i:] else: n2 = 0 val = cmp(n1, n2) if val != 0: return val # if numeric components equal, parse lexical components i = 0 for c in s1: if c in '0123456789': break i += 1 if i: l1 = s1[:i] s1 = s1[i:] else: l1 = '' i = 0 for c in s2: if c in '0123456789': break i += 1 if i: l2 = s2[:i] s2 = s2[i:] else: l2 = '' val = cmp(l1, l2) if val != 0: return val if s1 == s2: return 0
477,638
def main(): try: opts, args = getopt.getopt(sys.argv[1:], 'i:sqt', ['input=', 'strict', 'quiet', 'tree']) except getopt.GetoptError, e: usage(e) if not args: usage() outputdir = args[0] packages = args[1:] input = None opt_strict = False opt_quiet = False opt_tree = False for opt, val in opts: if opt in ('-i', '--input'): if val == '-': input = sys.stdin else: input = file(val, "r") elif opt in ('-s', '--strict'): opt_strict = True elif opt in ('-q', '--quiet'): opt_quiet = True elif opt in ('-t', '--tree'): opt_tree = True p = pool.Pool() if input: packages += read_packages(input) resolved = [] unresolved = [] for package in packages: if not p.exists(package): if opt_strict: fatal("%s: no such package" % package) if not opt_quiet: warn("%s: no such package" % package) continue if '=' in package: resolved.append(package) else: unresolved.append(package) if unresolved: resolved += fmt_package_tuples(cmd_list.list_packages(False, unresolved)) packages = resolved if not packages and not input: # if no packages specified, get all the newest versions packages = fmt_package_tuples(p.list()) for package in packages: path_from = p.getpath_deb(package) fname = basename(path_from) if opt_tree: package_name = package.split("=")[0] path_to = join(outputdir, get_treedir(package_name), fname) mkdir(dirname(path_to)) else: path_to = join(outputdir, basename(path_from)) if not exists(path_to): hardlink_or_copy(path_from, path_to) sys.exit(exitcode)
def main(): try: opts, args = getopt.getopt(sys.argv[1:], 'i:sqt', ['input=', 'strict', 'quiet', 'tree']) except getopt.GetoptError, e: usage(e) if not args: usage() outputdir = args[0] packages = args[1:] input = None opt_strict = False opt_quiet = False opt_tree = False for opt, val in opts: if opt in ('-i', '--input'): if val == '-': input = sys.stdin else: input = file(val, "r") elif opt in ('-s', '--strict'): opt_strict = True elif opt in ('-q', '--quiet'): opt_quiet = True elif opt in ('-t', '--tree'): opt_tree = True p = pool.Pool() if input: packages += read_packages(input) resolved = [] unresolved = [] for package in packages: if not p.exists(package): if opt_strict: fatal("%s: no such package" % package) if not opt_quiet: warn("%s: no such package" % package) continue if '=' in package: resolved.append(package) else: unresolved.append(package) if unresolved: resolved += fmt_package_tuples(cmd_list.list_packages(False, unresolved)) packages = resolved if not args[1:] and not input: # if no packages specified, get all the newest versions packages = fmt_package_tuples(p.list()) for package in packages: path_from = p.getpath_deb(package) fname = basename(path_from) if opt_tree: package_name = package.split("=")[0] path_to = join(outputdir, get_treedir(package_name), fname) mkdir(dirname(path_to)) else: path_to = join(outputdir, basename(path_from)) if not exists(path_to): hardlink_or_copy(path_from, path_to) sys.exit(exitcode)
477,639
def main(): try: opts, args = getopt.getopt(sys.argv[1:], 'an', ['all-versions', 'name-only']) except getopt.GetoptError, e: usage(e) opt_all_versions = False opt_name_only = False for opt, val in opts: if opt in ('-a', '--all-versions'): opt_all_versions = True elif opt in ('-n', '--name-only'): opt_name_only = True if opt_name_only and opt_all_versions: fatal("--name-only and --all-versions are conflicting options") globs = args packages = list_packages(opt_all_versions, globs) packages.sort(reverse=True) if opt_name_only: names = set() for name, version in packages: names.add(name) for name in names: print name else: for name, version in packages: print "%s=%s" % (name, version)
def main(): try: opts, args = getopt.getopt(sys.argv[1:], 'an', ['all-versions', 'name-only']) except getopt.GetoptError, e: usage(e) opt_all_versions = False opt_name_only = False for opt, val in opts: if opt in ('-a', '--all-versions'): opt_all_versions = True elif opt in ('-n', '--name-only'): opt_name_only = True if opt_name_only and opt_all_versions: fatal("--name-only and --all-versions are conflicting options") globs = args packages = list_packages(opt_all_versions, globs) def _cmp(a, b): val = cmp(b[0], a[0]) if val != 0: return val return debversion.compare(a[1], b[1]) packages.sort(cmp=_cmp, reverse=True) if opt_name_only: names = set() for name, version in packages: names.add(name) for name in names: print name else: for name, version in packages: print "%s=%s" % (name, version)
477,640
def create(cls, path, link): mkdir(path) paths = self.Paths(path) os.symlink(realpath(link), paths.link)
def create(cls, path, link): mkdir(path) paths = cls.Paths(path) os.symlink(realpath(link), paths.link)
477,641
def _sync_update_source_versions(self, dir): """update versions for a particular source package at <dir>""" packages = deb_get_packages(dir) versions = verseek.list(dir)
def _sync_update_source_versions(self, dir): """update versions for a particular source package at <dir>""" packages = deb_get_packages(dir) versions = verseek.list(dir)
477,642
def sync(self): """sync stock by updating source versions and importing binaries into the cache"""
def sync(self): """sync stock by updating source versions and importing binaries into the cache"""
477,643
def print_info(self): if len(self.stocks): print "# stocks" for stock in self.stocks: addr = stock.link if stock.branch: addr += "#" + stock.branch print addr
def print_info(self): if len(self.stocks): print "# stocks" for stock in self.stocks: addr = stock.link if stock.branch: addr += "#" + stock.branch print addr
477,644
def unregister(self, stock): dir, branch = self._parse_stock(stock) stock_name = basename(dir) if branch: stock_name += "#" + branch matches = [ stock for stock in self.stocks.values() if stock.link == dir and (not branch or stock.branch == branch) ] if not matches: raise Error("no matches for unregister")
def unregister(self, stock): dir, branch = self._parse_stock(stock) stock_name = basename(dir) if branch: stock_name += "#" + branch matches = [ stock for stock in self.stocks.values() if stock.link == dir and (not branch or stock.branch == branch) ] if not matches: raise Error("no matches for unregister")
477,645
def unregister(self, stock): dir, branch = self._parse_stock(stock) stock_name = basename(dir) if branch: stock_name += "#" + branch matches = [ stock for stock in self.stocks.values() if stock.link == dir and (not branch or stock.branch == branch) ] if not matches: raise Error("no matches for unregister")
def unregister(self, stock): dir, branch = self._parse_stock(stock) stock_name = basename(dir) if branch: stock_name += "#" + branch matches = [ stock for stock in self.stocks.values() if stock.link == dir and (not branch or stock.branch == branch) ] if not matches: raise Error("no matches for unregister")
477,646
def list(self, all_versions=False): """List packages in pool -> list of (name, version) tuples.
def list(self, all_versions=False): """List packages in pool -> list of (name, version) tuples.
477,647
def _get_workdir(self): """Return an initialized workdir path.
def _get_workdir(self): """Return an initialized workdir path.
477,648
def rev_parse(self, rev): """git-rev-parse <rev>. Returns object-id of parsed rev. Returns None on failure. """ try: return self._getoutput("git-rev-parse", rev + "^0") except self.Error: return None
def rev_parse(self, rev): """git-rev-parse <rev>. Returns object-id of parsed rev. Returns None on failure. """ try: return self._getoutput("git-rev-parse", rev) except self.Error: return None
477,649
def allow_args_openconn(desthost, destport, localip=None, localport=0, timeout=5): # TODO: the wiki:RepyLibrary gives localport=0 as the default for this function, # slightly different than the localport=None it gives for sendmess(). This # should either be verified as intentional or made the same. _require_string(desthost) _require_integer(destport) # The user must provide either both or neither of localip and localport, # but we're going to let the actual sendmess worry about that. if localip is not None: _require_string(localip) # We accept a localport of None to mean the same thing as 0. if localport is not None: _require_integer(localport) _require_integer_or_float(timeout)
def allow_args_openconn(desthost, destport, localip=None, localport=0, timeout=5): # TODO: the wiki:RepyLibrary gives localport=0 as the default for this function, # slightly different than the localport=None it gives for sendmess(). This # should either be verified as intentional or made the same. _require_string(desthost) _require_integer(destport) # The user must provide either both or neither of localip and localport, # but we're going to let the actual sendmess worry about that. if localip is not None: _require_string(localip) # We accept a localport of None to mean the same thing as 0. if localport is not None: _require_integer(localport) if timeout is not None: _require_integer_or_float(timeout)
477,650
def foo(): exitall()
def foo(): if mycontext['winner'] == None: mycontext['winner'] = 'timer'
477,651
def foo(): exitall()
def foo(): exitall()
477,652
def foo(): exitall()
def foo(): exitall()
477,653
def main(): """ <Purpose> Executes the main program that is the unit testing framework. Tests different modules, files, capabilities, dependent on command line arguments. <Arguments> None <Exceptions> None. <Side Effects> None <Returns> None """ ### ### Define allowed arguments. ### parser = optparse.OptionParser() ### Generic Option Category. group_generic = optparse.OptionGroup(parser, "Generic") # Verbose flag. group_generic.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, help="verbose output") # Verbose flag. group_generic.add_option("-T", "--show-time", action="store_true", dest="show_time", default=False, help="display the time taken to execute a test.") parser.add_option_group(group_generic) ### Testing Option Category. group_test = optparse.OptionGroup(parser, "Testing") # Test for a specific module. group_test.add_option("-m", "--module", dest="module", help="run tests for a specific module", metavar="MODULE") # Run a specific test file. group_test.add_option("-f", "--file", dest="file", help="execute a specific test file", metavar="FILE") # Run all tests in current directory group_test.add_option("-a", "--all", dest="all", action="store_true", help="execute all test files", metavar="ALL") parser.add_option_group(group_test) # All files in the current working directory. all_files = glob.glob("*") # Valid test files in the current working directory. valid_files = filter_files(all_files) ### # Parse the arguments. ### (options, args) = parser.parse_args() #Count number of args for legal number of args test i = 0 if (options.module): i = i + 1 if (options.all): i = i + 1 if (options.file): i = i + 1 # Test for mutual exclusion. if i > 1: parser.error("Options are mutually exclusive!") # Check if the show_time option is on. if (options.show_time): global SHOW_TIME SHOW_TIME = True if (options.file): # Single file. file_path = options.file test_single(file_path) elif (options.module): # Entire module. # Retrieve the module name. module_name = options.module module_file_list = filter_files(valid_files, module = module_name) test_module(module_name, module_file_list) elif (options.all): #all test files test_all(valid_files) else: # If no options are present, print the usage print "Usage: python utf.py (-f filename | -m modulename | -a)" print "-f -- test a specific filename" print "-m -- test a module of modulename" print "-a -- run all tests in current directory"
def main(): """ <Purpose> Executes the main program that is the unit testing framework. Tests different modules, files, capabilities, dependent on command line arguments. <Arguments> None <Exceptions> None. <Side Effects> None <Returns> None """ ### ### Define allowed arguments. ### parser = optparse.OptionParser() ### Generic Option Category. group_generic = optparse.OptionGroup(parser, "Generic") # Verbose flag. group_generic.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, help="verbose output") # Verbose flag. group_generic.add_option("-T", "--show-time", action="store_true", dest="show_time", default=False, help="display the time taken to execute a test.") parser.add_option_group(group_generic) ### Testing Option Category. group_test = optparse.OptionGroup(parser, "Testing") # Test for a specific module. group_test.add_option("-m", "--module", dest="module", help="run tests for a specific module", metavar="MODULE") # Run a specific test file. group_test.add_option("-f", "--file", dest="file", help="execute a specific test file", metavar="FILE") # Run all tests in current directory group_test.add_option("-a", "--all", dest="all", action="store_true", help="execute all test files", metavar="ALL") parser.add_option_group(group_test) # All files in the current working directory. all_files = glob.glob("*") # Valid test files in the current working directory. valid_files = filter_files(all_files) ### # Parse the arguments. ### (options, args) = parser.parse_args() #Count number of args for legal number of args test i = 0 if (options.module): i = i + 1 if (options.all): i = i + 1 if (options.file): i = i + 1 # Test for mutual exclusion. if i > 1: parser.error("Options are mutually exclusive!") # Check if the show_time option is on. if (options.show_time): global SHOW_TIME SHOW_TIME = True if (options.file): # Single file. file_path = options.file if not file_path.startswith('ut_') or len(file_path.split('_'))<3: print "Error, cannot determine module name from filename '"+file_path+"'" return else: module_name = file_path.split('_')[1] files_to_use = [file_path] module_file_list = filter_files(valid_files, module = module_name) files_to_use = files_to_use + filter_files(module_file_list, descriptor = 'setup') files_to_use = files_to_use + filter_files(module_file_list, descriptor = 'shutdown') files_to_use = files_to_use + filter_files(module_file_list, descriptor = 'subprocess') test_module(module_name, files_to_use) elif (options.module): # Entire module. # Retrieve the module name. module_name = options.module module_file_list = filter_files(valid_files, module = module_name) test_module(module_name, module_file_list) elif (options.all): #all test files test_all(valid_files) else: # If no options are present, print the usage print "Usage: python utf.py (-f filename | -m modulename | -a)" print "-f -- test a specific filename" print "-m -- test a module of modulename" print "-a -- run all tests in current directory"
477,654
def test_single(file_path): """ <Purpose> Given the test file path, this function will execute the test using the test framework. <Arguments> Test file path. <Exceptions> None. <Side Effects> None <Returns> None """ file_path = os.path.normpath(file_path) testing_monitor(file_path)
def execute_and_check_program(file_path): """ <Purpose> Given the test file path, this function will execute the program and monitor its behavior <Arguments> Test file path. <Exceptions> None. <Side Effects> None <Returns> None """ file_path = os.path.normpath(file_path) testing_monitor(file_path)
477,655
def test_module(module_name, module_file_list): """ <Purpose> Execute all test files contained within module_file_list matching the module_name in the form of each test file name 'ut_<module_name>_<descriptor>.py' <Arguments> module_name: module name to be tested module_file_list: a list of files to be filtered by module name and ran through the testing framework <Exceptions> None <Side Effects> None <Returns> None """ print 'Testing module:', module_name setup_file = None # Given all test files for the specified module name, find the file whose # descriptor equals 'setup' (there can be only one such file name). filtered_files = filter_files(module_file_list, descriptor = 'setup') if filtered_files: setup_file = filtered_files.pop() module_file_list.remove(setup_file) subprocess_file = None filtered_files = filter_files(module_file_list, descriptor = 'subprocess') if filtered_files: subprocess_file = filtered_files.pop() module_file_list.remove(subprocess_file) shutdown_file = None # Given all test files for the specified module name, find the file whose # descriptor equals 'shutdown' (there can be only one such file name). filtered_files = filter_files(module_file_list, descriptor = 'shutdown') if filtered_files: shutdown_file = filtered_files.pop() module_file_list.remove(shutdown_file) sub = None # If we must open a process to run concurrently with the tests if subprocess_file: print "Now starting subprocess: " + subprocess_file sub = subprocess.Popen(['python', subprocess_file]) # Give the process time to start time.sleep(30) if setup_file: print "Now running setup script: " + setup_file test_single(setup_file) start_time = time.time() # Run the module tests for test_file in module_file_list: test_single(test_file) end_time = time.time() if shutdown_file: print "Now running shutdown script: " + shutdown_file test_single(shutdown_file) #If we opened a subprocess, we need to be sure to kill it if sub: print "Now killing subprocess: " + subprocess_file if sys.version_info < (2, 6): # Using portablekill instead of os.kill as it is more uniform across os. harshexit.portablekill(sub.pid) else: sub.kill() if SHOW_TIME: print "Total time taken to run tests on module %s is: %s" % (module_name, str(end_time-start_time)[:6])
def test_module(module_name, module_file_list): """ <Purpose> Execute all test files contained within module_file_list matching the module_name in the form of each test file name 'ut_<module_name>_<descriptor>.py' <Arguments> module_name: module name to be tested module_file_list: a list of files to be filtered by module name and ran through the testing framework <Exceptions> None <Side Effects> None <Returns> None """ print 'Testing module:', module_name setup_file = None # Given all test files for the specified module name, find the file whose # descriptor equals 'setup' (there can be only one such file name). filtered_files = filter_files(module_file_list, descriptor = 'setup') if filtered_files: setup_file = filtered_files.pop() module_file_list.remove(setup_file) subprocess_file = None filtered_files = filter_files(module_file_list, descriptor = 'subprocess') if filtered_files: subprocess_file = filtered_files.pop() module_file_list.remove(subprocess_file) shutdown_file = None # Given all test files for the specified module name, find the file whose # descriptor equals 'shutdown' (there can be only one such file name). filtered_files = filter_files(module_file_list, descriptor = 'shutdown') if filtered_files: shutdown_file = filtered_files.pop() module_file_list.remove(shutdown_file) sub = None # If we must open a process to run concurrently with the tests if subprocess_file: print "Now starting subprocess: " + subprocess_file sub = subprocess.Popen(['python', subprocess_file]) # Give the process time to start time.sleep(30) if setup_file: print "Now running setup script: " + setup_file execute_and_check_program(setup_file) start_time = time.time() # Run the module tests for test_file in module_file_list: test_single(test_file) end_time = time.time() if shutdown_file: print "Now running shutdown script: " + shutdown_file test_single(shutdown_file) #If we opened a subprocess, we need to be sure to kill it if sub: print "Now killing subprocess: " + subprocess_file if sys.version_info < (2, 6): # Using portablekill instead of os.kill as it is more uniform across os. harshexit.portablekill(sub.pid) else: sub.kill() if SHOW_TIME: print "Total time taken to run tests on module %s is: %s" % (module_name, str(end_time-start_time)[:6])
477,656
def test_module(module_name, module_file_list): """ <Purpose> Execute all test files contained within module_file_list matching the module_name in the form of each test file name 'ut_<module_name>_<descriptor>.py' <Arguments> module_name: module name to be tested module_file_list: a list of files to be filtered by module name and ran through the testing framework <Exceptions> None <Side Effects> None <Returns> None """ print 'Testing module:', module_name setup_file = None # Given all test files for the specified module name, find the file whose # descriptor equals 'setup' (there can be only one such file name). filtered_files = filter_files(module_file_list, descriptor = 'setup') if filtered_files: setup_file = filtered_files.pop() module_file_list.remove(setup_file) subprocess_file = None filtered_files = filter_files(module_file_list, descriptor = 'subprocess') if filtered_files: subprocess_file = filtered_files.pop() module_file_list.remove(subprocess_file) shutdown_file = None # Given all test files for the specified module name, find the file whose # descriptor equals 'shutdown' (there can be only one such file name). filtered_files = filter_files(module_file_list, descriptor = 'shutdown') if filtered_files: shutdown_file = filtered_files.pop() module_file_list.remove(shutdown_file) sub = None # If we must open a process to run concurrently with the tests if subprocess_file: print "Now starting subprocess: " + subprocess_file sub = subprocess.Popen(['python', subprocess_file]) # Give the process time to start time.sleep(30) if setup_file: print "Now running setup script: " + setup_file test_single(setup_file) start_time = time.time() # Run the module tests for test_file in module_file_list: test_single(test_file) end_time = time.time() if shutdown_file: print "Now running shutdown script: " + shutdown_file test_single(shutdown_file) #If we opened a subprocess, we need to be sure to kill it if sub: print "Now killing subprocess: " + subprocess_file if sys.version_info < (2, 6): # Using portablekill instead of os.kill as it is more uniform across os. harshexit.portablekill(sub.pid) else: sub.kill() if SHOW_TIME: print "Total time taken to run tests on module %s is: %s" % (module_name, str(end_time-start_time)[:6])
def test_module(module_name, module_file_list): """ <Purpose> Execute all test files contained within module_file_list matching the module_name in the form of each test file name 'ut_<module_name>_<descriptor>.py' <Arguments> module_name: module name to be tested module_file_list: a list of files to be filtered by module name and ran through the testing framework <Exceptions> None <Side Effects> None <Returns> None """ print 'Testing module:', module_name setup_file = None # Given all test files for the specified module name, find the file whose # descriptor equals 'setup' (there can be only one such file name). filtered_files = filter_files(module_file_list, descriptor = 'setup') if filtered_files: setup_file = filtered_files.pop() module_file_list.remove(setup_file) subprocess_file = None filtered_files = filter_files(module_file_list, descriptor = 'subprocess') if filtered_files: subprocess_file = filtered_files.pop() module_file_list.remove(subprocess_file) shutdown_file = None # Given all test files for the specified module name, find the file whose # descriptor equals 'shutdown' (there can be only one such file name). filtered_files = filter_files(module_file_list, descriptor = 'shutdown') if filtered_files: shutdown_file = filtered_files.pop() module_file_list.remove(shutdown_file) sub = None # If we must open a process to run concurrently with the tests if subprocess_file: print "Now starting subprocess: " + subprocess_file sub = subprocess.Popen(['python', subprocess_file]) # Give the process time to start time.sleep(30) if setup_file: print "Now running setup script: " + setup_file test_single(setup_file) start_time = time.time() # Run the module tests for test_file in module_file_list: execute_and_check_program(test_file) end_time = time.time() if shutdown_file: print "Now running shutdown script: " + shutdown_file test_single(shutdown_file) #If we opened a subprocess, we need to be sure to kill it if sub: print "Now killing subprocess: " + subprocess_file if sys.version_info < (2, 6): # Using portablekill instead of os.kill as it is more uniform across os. harshexit.portablekill(sub.pid) else: sub.kill() if SHOW_TIME: print "Total time taken to run tests on module %s is: %s" % (module_name, str(end_time-start_time)[:6])
477,657
def test_module(module_name, module_file_list): """ <Purpose> Execute all test files contained within module_file_list matching the module_name in the form of each test file name 'ut_<module_name>_<descriptor>.py' <Arguments> module_name: module name to be tested module_file_list: a list of files to be filtered by module name and ran through the testing framework <Exceptions> None <Side Effects> None <Returns> None """ print 'Testing module:', module_name setup_file = None # Given all test files for the specified module name, find the file whose # descriptor equals 'setup' (there can be only one such file name). filtered_files = filter_files(module_file_list, descriptor = 'setup') if filtered_files: setup_file = filtered_files.pop() module_file_list.remove(setup_file) subprocess_file = None filtered_files = filter_files(module_file_list, descriptor = 'subprocess') if filtered_files: subprocess_file = filtered_files.pop() module_file_list.remove(subprocess_file) shutdown_file = None # Given all test files for the specified module name, find the file whose # descriptor equals 'shutdown' (there can be only one such file name). filtered_files = filter_files(module_file_list, descriptor = 'shutdown') if filtered_files: shutdown_file = filtered_files.pop() module_file_list.remove(shutdown_file) sub = None # If we must open a process to run concurrently with the tests if subprocess_file: print "Now starting subprocess: " + subprocess_file sub = subprocess.Popen(['python', subprocess_file]) # Give the process time to start time.sleep(30) if setup_file: print "Now running setup script: " + setup_file test_single(setup_file) start_time = time.time() # Run the module tests for test_file in module_file_list: test_single(test_file) end_time = time.time() if shutdown_file: print "Now running shutdown script: " + shutdown_file test_single(shutdown_file) #If we opened a subprocess, we need to be sure to kill it if sub: print "Now killing subprocess: " + subprocess_file if sys.version_info < (2, 6): # Using portablekill instead of os.kill as it is more uniform across os. harshexit.portablekill(sub.pid) else: sub.kill() if SHOW_TIME: print "Total time taken to run tests on module %s is: %s" % (module_name, str(end_time-start_time)[:6])
def test_module(module_name, module_file_list): """ <Purpose> Execute all test files contained within module_file_list matching the module_name in the form of each test file name 'ut_<module_name>_<descriptor>.py' <Arguments> module_name: module name to be tested module_file_list: a list of files to be filtered by module name and ran through the testing framework <Exceptions> None <Side Effects> None <Returns> None """ print 'Testing module:', module_name setup_file = None # Given all test files for the specified module name, find the file whose # descriptor equals 'setup' (there can be only one such file name). filtered_files = filter_files(module_file_list, descriptor = 'setup') if filtered_files: setup_file = filtered_files.pop() module_file_list.remove(setup_file) subprocess_file = None filtered_files = filter_files(module_file_list, descriptor = 'subprocess') if filtered_files: subprocess_file = filtered_files.pop() module_file_list.remove(subprocess_file) shutdown_file = None # Given all test files for the specified module name, find the file whose # descriptor equals 'shutdown' (there can be only one such file name). filtered_files = filter_files(module_file_list, descriptor = 'shutdown') if filtered_files: shutdown_file = filtered_files.pop() module_file_list.remove(shutdown_file) sub = None # If we must open a process to run concurrently with the tests if subprocess_file: print "Now starting subprocess: " + subprocess_file sub = subprocess.Popen(['python', subprocess_file]) # Give the process time to start time.sleep(30) if setup_file: print "Now running setup script: " + setup_file test_single(setup_file) start_time = time.time() # Run the module tests for test_file in module_file_list: test_single(test_file) end_time = time.time() if shutdown_file: print "Now running shutdown script: " + shutdown_file execute_and_check_program(shutdown_file) #If we opened a subprocess, we need to be sure to kill it if sub: print "Now killing subprocess: " + subprocess_file if sys.version_info < (2, 6): # Using portablekill instead of os.kill as it is more uniform across os. harshexit.portablekill(sub.pid) else: sub.kill() if SHOW_TIME: print "Total time taken to run tests on module %s is: %s" % (module_name, str(end_time-start_time)[:6])
477,658
def _create_rss_file(resultslist): failureitems = [] for (runnumber, revision, resulttext) in resultslist: if resulttext[0].strip() != "SUCCESS": datestr = resulttext[1].strip() dateobj = datetime.datetime.strptime(datestr, "%Y-%m-%d %H:%M:%S") # The PyRSS2Gen module expects this to be in GMT, and python is a pain # for timezone conversion. I'll just hard code assuming the system's in # PST and ignore daylight savings time. dateobj += datetime.timedelta(hours=8) item = PyRSS2Gen.RSSItem( title="Test failure on run number " + str(runnumber) + " using " + revision, link=config.TESTLOG_URL, description="\n".join(resulttext), # Spaces aren't valid in a guid. guid=PyRSS2Gen.Guid(config.TESTLOG_URL + datestr.replace(' ', '_')), pubDate=dateobj) failureitems.append(item) rss = PyRSS2Gen.RSS2( title="Test Failures on " + config.SYSTEM_DESCRIPTION, link=config.TESTLOG_URL, description="Seattle test failures for continuous build on " + config.SYSTEM_DESCRIPTION, lastBuildDate=datetime.datetime.now() + datetime.timedelta(hours=8), items=failureitems) rss.write_xml(open(config.RSS_FILE_NAME + ".new", "w")) os.rename(config.RSS_FILE_NAME + ".new", config.RSS_FILE_NAME)
def _create_rss_file(resultslist): failureitems = [] for (runnumber, revision, resulttext) in resultslist: if resulttext[0].strip() != "SUCCESS": datestr = resulttext[1].strip() dateobj = datetime.datetime.strptime(datestr, "%Y-%m-%d %H:%M:%S") # The PyRSS2Gen module expects this to be in GMT, and python is a pain # for timezone conversion. I'll just hard code assuming the system's in # PST and ignore daylight savings time. dateobj += datetime.timedelta(hours=8) item = PyRSS2Gen.RSSItem( title="Test failure on run number " + str(runnumber) + " using " + revision, link=config.TESTLOG_URL, description="\n".join(resulttext), # Spaces aren't valid in a guid. guid=PyRSS2Gen.Guid(config.TESTLOG_URL + str(runnumber)), pubDate=dateobj) failureitems.append(item) rss = PyRSS2Gen.RSS2( title="Test Failures on " + config.SYSTEM_DESCRIPTION, link=config.TESTLOG_URL, description="Seattle test failures for continuous build on " + config.SYSTEM_DESCRIPTION, lastBuildDate=datetime.datetime.now() + datetime.timedelta(hours=8), items=failureitems) rss.write_xml(open(config.RSS_FILE_NAME + ".new", "w")) os.rename(config.RSS_FILE_NAME + ".new", config.RSS_FILE_NAME)
477,659
def main(): # initialize the gmail module success,explanation_str = send_gmail.init_gmail() if not success: integrationtestlib.log(explanation_str) sys.exit(0) notify_str = '' #add Eric Kimbrel to the email notify list integrationtestlib.notify_list.append("lekimbrel@gmail.com") integrationtestlib.log("Starting test_time_tcp.py...") # get the time 5 times and make sure they are reasonably close test_start = getruntime() times = [] for i in range (5): try: tcp_time_updatetime(12345) times.append(time_gettime()) except Exception,e: pass test_stop1 = getruntime() if len(times) < 4: # more than one attempt failed notify_str += 'failed to get ntp time via tcp at least twice in 5 attempts' diff = max(times) - min(times) if diff > (test_stop1 - test_start): integrationtestlib.log('WARNING large descrepancy between tcp times: '+str(diff)) notify_str += ' WARNING large descrepancy between tcp times: '+str(diff) try: ntp_time_updatetime(12345) ntp_t = time_gettime() except Exception,e: fail_test(str(e)) test_stop2 = getruntime() diff = ntp_t - max(times) if diff > (8 + test_stop2 - test_stop1): exceedby = diff - (test_stop2-test_stop1) integrationtestlib.log('WARING large descrepancy between ntp and tcp times') notify_str += ' WARNING large descrepancy between ntp and tcp time: '+str(exceedby) if notify_str != '': integrationtestlib.notify(notify_str, "test_time_tcp test failed") else: integrationtestlib.log("Finished running test_time_tcp.py..... Test Passed") print "......................................................\n"
def main(): # initialize the gmail module success,explanation_str = send_gmail.init_gmail() if not success: integrationtestlib.log(explanation_str) sys.exit(0) notify_str = '' #add Eric Kimbrel to the email notify list integrationtestlib.notify_list.append("lekimbrel@gmail.com") integrationtestlib.log("Starting test_time_tcp.py...") # get the time 5 times and make sure they are reasonably close test_start = getruntime() times = [] for i in range (5): try: connected_server = tcp_time_updatetime(12345) current_time = time_gettime() times.append(current_time) server_list.append(connected_server) integrationtestlib.log("Calling time_gettime(). Retrieved time: " + str(current_time)) except Exception,e: pass test_stop1 = getruntime() if len(times) < 4: # more than one attempt failed notify_str += 'failed to get ntp time via tcp at least twice in 5 attempts' diff = max(times) - min(times) if diff > (test_stop1 - test_start): integrationtestlib.log('WARNING large descrepancy between tcp times: '+str(diff)) notify_str += ' WARNING large descrepancy between tcp times: '+str(diff) try: ntp_time_updatetime(12345) ntp_t = time_gettime() except Exception,e: fail_test(str(e)) test_stop2 = getruntime() diff = ntp_t - max(times) if diff > (8 + test_stop2 - test_stop1): exceedby = diff - (test_stop2-test_stop1) integrationtestlib.log('WARING large descrepancy between ntp and tcp times') notify_str += ' WARNING large descrepancy between ntp and tcp time: '+str(exceedby) if notify_str != '': integrationtestlib.notify(notify_str, "test_time_tcp test failed") else: integrationtestlib.log("Finished running test_time_tcp.py..... Test Passed") print "......................................................\n"
477,660
def main(): # initialize the gmail module success,explanation_str = send_gmail.init_gmail() if not success: integrationtestlib.log(explanation_str) sys.exit(0) notify_str = '' #add Eric Kimbrel to the email notify list integrationtestlib.notify_list.append("lekimbrel@gmail.com") integrationtestlib.log("Starting test_time_tcp.py...") # get the time 5 times and make sure they are reasonably close test_start = getruntime() times = [] for i in range (5): try: tcp_time_updatetime(12345) times.append(time_gettime()) except Exception,e: pass test_stop1 = getruntime() if len(times) < 4: # more than one attempt failed notify_str += 'failed to get ntp time via tcp at least twice in 5 attempts' diff = max(times) - min(times) if diff > (test_stop1 - test_start): integrationtestlib.log('WARNING large descrepancy between tcp times: '+str(diff)) notify_str += ' WARNING large descrepancy between tcp times: '+str(diff) try: ntp_time_updatetime(12345) ntp_t = time_gettime() except Exception,e: fail_test(str(e)) test_stop2 = getruntime() diff = ntp_t - max(times) if diff > (8 + test_stop2 - test_stop1): exceedby = diff - (test_stop2-test_stop1) integrationtestlib.log('WARING large descrepancy between ntp and tcp times') notify_str += ' WARNING large descrepancy between ntp and tcp time: '+str(exceedby) if notify_str != '': integrationtestlib.notify(notify_str, "test_time_tcp test failed") else: integrationtestlib.log("Finished running test_time_tcp.py..... Test Passed") print "......................................................\n"
def main(): # initialize the gmail module success,explanation_str = send_gmail.init_gmail() if not success: integrationtestlib.log(explanation_str) sys.exit(0) notify_str = '' #add Eric Kimbrel to the email notify list integrationtestlib.notify_list.append("lekimbrel@gmail.com") integrationtestlib.log("Starting test_time_tcp.py...") # get the time 5 times and make sure they are reasonably close test_start = getruntime() times = [] for i in range (5): try: tcp_time_updatetime(12345) times.append(time_gettime()) except Exception,e: pass test_stop1 = getruntime() if len(times) < 4: # more than one attempt failed notify_str += 'failed to get ntp time via tcp at least twice in 5 attempts' diff = max(times) - min(times) if diff > (test_stop1 - test_start): integrationtestlib.log('WARNING large descrepancy between tcp times: '+str(diff)) notify_str += ' WARNING large descrepancy between tcp times: '+str(diff) try: ntp_time_updatetime(12345) ntp_t = time_gettime() except Exception,e: fail_test(str(e)) test_stop2 = getruntime() diff = ntp_t - max(times) if diff > (8 + test_stop2 - test_stop1): exceedby = diff - (test_stop2-test_stop1) integrationtestlib.log('WARING large descrepancy between ntp and tcp times') notify_str += ' WARNING large descrepancy between ntp and tcp time: '+str(exceedby) if notify_str != '': integrationtestlib.notify(notify_str, "test_time_tcp test failed") else: integrationtestlib.log("Finished running test_time_tcp.py..... Test Passed") print "......................................................\n"
477,661
def main(): # initialize the gmail module success,explanation_str = send_gmail.init_gmail() if not success: integrationtestlib.log(explanation_str) sys.exit(0) notify_str = '' #add Eric Kimbrel to the email notify list integrationtestlib.notify_list.append("lekimbrel@gmail.com") integrationtestlib.log("Starting test_time_tcp.py...") # get the time 5 times and make sure they are reasonably close test_start = getruntime() times = [] for i in range (5): try: tcp_time_updatetime(12345) times.append(time_gettime()) except Exception,e: pass test_stop1 = getruntime() if len(times) < 4: # more than one attempt failed notify_str += 'failed to get ntp time via tcp at least twice in 5 attempts' diff = max(times) - min(times) if diff > (test_stop1 - test_start): integrationtestlib.log('WARNING large descrepancy between tcp times: '+str(diff)) notify_str += ' WARNING large descrepancy between tcp times: '+str(diff) try: ntp_time_updatetime(12345) ntp_t = time_gettime() except Exception,e: fail_test(str(e)) test_stop2 = getruntime() diff = ntp_t - max(times) if diff > (8 + test_stop2 - test_stop1): exceedby = diff - (test_stop2-test_stop1) integrationtestlib.log('WARING large descrepancy between ntp and tcp times') notify_str += ' WARNING large descrepancy between ntp and tcp time: '+str(exceedby) if notify_str != '': integrationtestlib.notify(notify_str, "test_time_tcp test failed") else: integrationtestlib.log("Finished running test_time_tcp.py..... Test Passed") print "......................................................\n"
def main(): # initialize the gmail module success,explanation_str = send_gmail.init_gmail() if not success: integrationtestlib.log(explanation_str) sys.exit(0) notify_str = '' #add Eric Kimbrel to the email notify list integrationtestlib.notify_list.append("lekimbrel@gmail.com") integrationtestlib.log("Starting test_time_tcp.py...") # get the time 5 times and make sure they are reasonably close test_start = getruntime() times = [] for i in range (5): try: tcp_time_updatetime(12345) times.append(time_gettime()) except Exception,e: pass test_stop1 = getruntime() if len(times) < 4: # more than one attempt failed notify_str += "failed to get ntp time via tcp at least twice in 5 attempts\n\n" notify_str += "Appending a list of all the exceptions returned and servers we attempted to connect to:\n\n" notify_str += str(exception_string_list) diff = max(times) - min(times) if diff > (test_stop1 - test_start): integrationtestlib.log('WARNING large descrepancy between tcp times: '+str(diff)) notify_str += ' WARNING large descrepancy between tcp times: '+str(diff) try: ntp_time_updatetime(12345) ntp_t = time_gettime() except Exception,e: fail_test(str(e)) test_stop2 = getruntime() diff = ntp_t - max(times) if diff > (8 + test_stop2 - test_stop1): exceedby = diff - (test_stop2-test_stop1) integrationtestlib.log('WARING large descrepancy between ntp and tcp times') notify_str += ' WARNING large descrepancy between ntp and tcp time: '+str(exceedby) if notify_str != '': integrationtestlib.notify(notify_str, "test_time_tcp test failed") else: integrationtestlib.log("Finished running test_time_tcp.py..... Test Passed") print "......................................................\n"
477,662
def main(): # initialize the gmail module success,explanation_str = send_gmail.init_gmail() if not success: integrationtestlib.log(explanation_str) sys.exit(0) notify_str = '' #add Eric Kimbrel to the email notify list integrationtestlib.notify_list.append("lekimbrel@gmail.com") integrationtestlib.log("Starting test_time_tcp.py...") # get the time 5 times and make sure they are reasonably close test_start = getruntime() times = [] for i in range (5): try: tcp_time_updatetime(12345) times.append(time_gettime()) except Exception,e: pass test_stop1 = getruntime() if len(times) < 4: # more than one attempt failed notify_str += 'failed to get ntp time via tcp at least twice in 5 attempts' diff = max(times) - min(times) if diff > (test_stop1 - test_start): integrationtestlib.log('WARNING large descrepancy between tcp times: '+str(diff)) notify_str += ' WARNING large descrepancy between tcp times: '+str(diff) try: ntp_time_updatetime(12345) ntp_t = time_gettime() except Exception,e: fail_test(str(e)) test_stop2 = getruntime() diff = ntp_t - max(times) if diff > (8 + test_stop2 - test_stop1): exceedby = diff - (test_stop2-test_stop1) integrationtestlib.log('WARING large descrepancy between ntp and tcp times') notify_str += ' WARNING large descrepancy between ntp and tcp time: '+str(exceedby) if notify_str != '': integrationtestlib.notify(notify_str, "test_time_tcp test failed") else: integrationtestlib.log("Finished running test_time_tcp.py..... Test Passed") print "......................................................\n"
def main(): # initialize the gmail module success,explanation_str = send_gmail.init_gmail() if not success: integrationtestlib.log(explanation_str) sys.exit(0) notify_str = '' #add Eric Kimbrel to the email notify list integrationtestlib.notify_list.append("lekimbrel@gmail.com") integrationtestlib.log("Starting test_time_tcp.py...") # get the time 5 times and make sure they are reasonably close test_start = getruntime() times = [] for i in range (5): try: tcp_time_updatetime(12345) times.append(time_gettime()) except Exception,e: pass test_stop1 = getruntime() if len(times) < 4: # more than one attempt failed notify_str += 'failed to get ntp time via tcp at least twice in 5 attempts' diff = max(times) - min(times) test_diff = test_stop1 - test_start if math.fabs(diff - test_diff) > 10: fail_test_str += ' WARNING large descrepancy between tcp times. \nThe difference between tcp_time diff and the actual test diff is: '+str(diff - test_diff) fail_test_str += "\n\nThe start time of test was: " + str(test_start) + ". The end time of test was: " + str(test_stop1) fail_test_str += "\n\nThe list of times returned by the tcp_server were: " + str(times) fail_test_str += "\n\nThe max time was: " + str(max(times)) + ". The min time was: " + str(min(times)) fail_test_str += ". \n\nThe tcp diff time was: " + str(diff) + ". This time should have been less then: " + str(test_diff) fail_test_str += "\n\nThe servers we connected to are: " + str(server_list) notify_str += fail_test_str integrationtestlib.log(fail_test_str) integrationtestlib.log("Local time diff: " + str(local_end_time - local_start_time)) try: ntp_time_updatetime(12345) ntp_t = time_gettime() except Exception,e: fail_test(str(e)) test_stop2 = getruntime() diff = ntp_t - max(times) if diff > (8 + test_stop2 - test_stop1): exceedby = diff - (test_stop2-test_stop1) integrationtestlib.log('WARING large descrepancy between ntp and tcp times') notify_str += ' WARNING large descrepancy between ntp and tcp time: '+str(exceedby) if notify_str != '': integrationtestlib.notify(notify_str, "test_time_tcp test failed") else: integrationtestlib.log("Finished running test_time_tcp.py..... Test Passed") print "......................................................\n"
477,663
def main(): # initialize the gmail module success,explanation_str = send_gmail.init_gmail() if not success: integrationtestlib.log(explanation_str) sys.exit(0) notify_str = '' #add Eric Kimbrel to the email notify list integrationtestlib.notify_list.append("lekimbrel@gmail.com") integrationtestlib.log("Starting test_time_tcp.py...") # get the time 5 times and make sure they are reasonably close test_start = getruntime() times = [] for i in range (5): try: tcp_time_updatetime(12345) times.append(time_gettime()) except Exception,e: pass test_stop1 = getruntime() if len(times) < 4: # more than one attempt failed notify_str += 'failed to get ntp time via tcp at least twice in 5 attempts' diff = max(times) - min(times) if diff > (test_stop1 - test_start): integrationtestlib.log('WARNING large descrepancy between tcp times: '+str(diff)) notify_str += ' WARNING large descrepancy between tcp times: '+str(diff) try: ntp_time_updatetime(12345) ntp_t = time_gettime() except Exception,e: fail_test(str(e)) test_stop2 = getruntime() diff = ntp_t - max(times) if diff > (8 + test_stop2 - test_stop1): exceedby = diff - (test_stop2-test_stop1) integrationtestlib.log('WARING large descrepancy between ntp and tcp times') notify_str += ' WARNING large descrepancy between ntp and tcp time: '+str(exceedby) if notify_str != '': integrationtestlib.notify(notify_str, "test_time_tcp test failed") else: integrationtestlib.log("Finished running test_time_tcp.py..... Test Passed") print "......................................................\n"
def main(): # initialize the gmail module success,explanation_str = send_gmail.init_gmail() if not success: integrationtestlib.log(explanation_str) sys.exit(0) notify_str = '' #add Eric Kimbrel to the email notify list integrationtestlib.notify_list.append("lekimbrel@gmail.com") integrationtestlib.log("Starting test_time_tcp.py...") # get the time 5 times and make sure they are reasonably close test_start = getruntime() times = [] for i in range (5): try: tcp_time_updatetime(12345) times.append(time_gettime()) except Exception,e: pass test_stop1 = getruntime() if len(times) < 4: # more than one attempt failed notify_str += 'failed to get ntp time via tcp at least twice in 5 attempts' diff = max(times) - min(times) if diff > (test_stop1 - test_start): integrationtestlib.log('WARNING large descrepancy between tcp times: '+str(diff)) notify_str += ' WARNING large descrepancy between tcp times: '+str(diff) try: ntp_time_updatetime(12345) ntp_t = time_gettime() except Exception,e: integrationtestlib.log("Failed to call ntp_time_updatetime(). Returned with exception: " +str(e)) notify_str += "\nFailed to call ntp_time_updatetime(). Returned with exception: " +str(e) test_stop2 = getruntime() diff = ntp_t - max(times) if diff > (8 + test_stop2 - test_stop1): exceedby = diff - (test_stop2-test_stop1) integrationtestlib.log('WARING large descrepancy between ntp and tcp times') notify_str += ' WARNING large descrepancy between ntp and tcp time: '+str(exceedby) if notify_str != '': integrationtestlib.notify(notify_str, "test_time_tcp test failed") else: integrationtestlib.log("Finished running test_time_tcp.py..... Test Passed") print "......................................................\n"
477,664
def _generate_python_file_from_repy(repyfilename, generatedfilename, shared_mycontext, callfunc, callargs): """ Generate a python module from a repy file so it can be imported The first line is TRANSLATION_TAGLINE, so it's easy to detect that the file was automatically generated """ #Start the generation! Print out the header and portability stuff, then include #the original data and translations try: # Create path if it doesn't exist. if not os.path.isdir(os.path.dirname(generatedfilename)): os.makedirs(os.path.dirname(generatedfilename)) fh = open(generatedfilename, "w") except IOError, e: # this is likely a directory permissions error raise TranslationError("Cannot open file for translation '" + repyfilename + "': " + str(e)) # always close the file try: print >> fh, TRANSLATION_TAGLINE, os.path.abspath(repyfilename) print >> fh, WARNING_LABEL print >> fh, "from repyportability import *" print >> fh, "import repyhelper" if shared_mycontext: print >> fh, "mycontext = repyhelper.get_shared_context()" else: print >> fh, "mycontext = {}" print >> fh, "callfunc =", repr(callfunc) #Properly format the callargs list. Assume it only contains python strings print >> fh, "callargs =", repr(callargs) print >> fh _process_output_file(fh, repyfilename, generatedfilename) # append the TRANSLATION_TAGLINE so that we can see if the operation was # interrupted (#617) print >> fh print >> fh, TRANSLATION_TAGLINE, os.path.abspath(repyfilename) except IOError, e: raise TranslationError("Error translating file " + repyfilename + ": " + str(e)) finally: fh.close()
def _generate_python_file_from_repy(repyfilename, generatedfilename, shared_mycontext, callfunc, callargs): """ Generate a python module from a repy file so it can be imported The first line is TRANSLATION_TAGLINE, so it's easy to detect that the file was automatically generated """ #Start the generation! Print out the header and portability stuff, then include #the original data and translations try: # Create path if it doesn't exist. if os.path.dirname(generatedfilename) != '' and not os.path.isdir(os.path.dirname(generatedfilename)): os.makedirs(os.path.dirname(generatedfilename)) fh = open(generatedfilename, "w") except IOError, e: # this is likely a directory permissions error raise TranslationError("Cannot open file for translation '" + repyfilename + "': " + str(e)) # always close the file try: print >> fh, TRANSLATION_TAGLINE, os.path.abspath(repyfilename) print >> fh, WARNING_LABEL print >> fh, "from repyportability import *" print >> fh, "import repyhelper" if shared_mycontext: print >> fh, "mycontext = repyhelper.get_shared_context()" else: print >> fh, "mycontext = {}" print >> fh, "callfunc =", repr(callfunc) #Properly format the callargs list. Assume it only contains python strings print >> fh, "callargs =", repr(callargs) print >> fh _process_output_file(fh, repyfilename, generatedfilename) # append the TRANSLATION_TAGLINE so that we can see if the operation was # interrupted (#617) print >> fh print >> fh, TRANSLATION_TAGLINE, os.path.abspath(repyfilename) except IOError, e: raise TranslationError("Error translating file " + repyfilename + ": " + str(e)) finally: fh.close()
477,665
def is_accepter_started(): acceptor_state['lock'].acquire() result = acceptor_state['started'] acceptor_state['lock'].release() return result
def is_accepter_started(): accepter_state['lock'].acquire() result = accepter_state['started'] accepter_state['lock'].release() return result
477,666
def start_accepter(): shimstack = ShimStackInterface('(NatDeciderShim)') unique_id = rsa_publickey_to_string(configuration['publickey']) unique_id = sha_hexhash(unique_id) + str(configuration['service_vessel']) # do this until we get the accepter started... while True: if is_accepter_started(): # we're done, return the name! return myname else: for possibleport in configuration['ports']: try: servicelogger.log("[INFO]: Trying to wait") shimstack.waitforconn(unique_id, possibleport, nmconnectionmanager.connection_handler) except Exception, e: servicelogger.log("[ERROR]: when calling waitforconn for the connection_handler: " + str(e)) servicelogger.log_last_exception() else: # the waitforconn was completed so the acceptor is started acceptor_state['lock'].acquire() acceptor_state['started']= True acceptor_state['lock'].release() # assign the nodemanager name myname = unique_id + ":" + str(possibleport) servicelogger.log("[INFO]: Now listening as " + myname) break else: servicelogger.log("[ERROR]: cannot find a port for waitforconn.") # check infrequently time.sleep(configuration['pollfrequency'])
def start_accepter(): shimstack = ShimStackInterface('(NatDeciderShim)') unique_id = rsa_publickey_to_string(configuration['publickey']) unique_id = sha_hexhash(unique_id) + str(configuration['service_vessel']) # do this until we get the accepter started... while True: if not node_reset_config['reset_accepter'] and is_accepter_started(): # we're done, return the name! return myname else: for possibleport in configuration['ports']: try: servicelogger.log("[INFO]: Trying to wait") shimstack.waitforconn(unique_id, possibleport, nmconnectionmanager.connection_handler) except Exception, e: servicelogger.log("[ERROR]: when calling waitforconn for the connection_handler: " + str(e)) servicelogger.log_last_exception() else: # the waitforconn was completed so the acceptor is started acceptor_state['lock'].acquire() acceptor_state['started']= True acceptor_state['lock'].release() # assign the nodemanager name myname = unique_id + ":" + str(possibleport) servicelogger.log("[INFO]: Now listening as " + myname) break else: servicelogger.log("[ERROR]: cannot find a port for waitforconn.") # check infrequently time.sleep(configuration['pollfrequency'])
477,667
def start_accepter(): shimstack = ShimStackInterface('(NatDeciderShim)') unique_id = rsa_publickey_to_string(configuration['publickey']) unique_id = sha_hexhash(unique_id) + str(configuration['service_vessel']) # do this until we get the accepter started... while True: if is_accepter_started(): # we're done, return the name! return myname else: for possibleport in configuration['ports']: try: servicelogger.log("[INFO]: Trying to wait") shimstack.waitforconn(unique_id, possibleport, nmconnectionmanager.connection_handler) except Exception, e: servicelogger.log("[ERROR]: when calling waitforconn for the connection_handler: " + str(e)) servicelogger.log_last_exception() else: # the waitforconn was completed so the acceptor is started acceptor_state['lock'].acquire() acceptor_state['started']= True acceptor_state['lock'].release() # assign the nodemanager name myname = unique_id + ":" + str(possibleport) servicelogger.log("[INFO]: Now listening as " + myname) break else: servicelogger.log("[ERROR]: cannot find a port for waitforconn.") # check infrequently time.sleep(configuration['pollfrequency'])
def start_accepter(): shimstack = ShimStackInterface('(NatDeciderShim)') unique_id = rsa_publickey_to_string(configuration['publickey']) unique_id = sha_hexhash(unique_id) + str(configuration['service_vessel']) # do this until we get the accepter started... while True: if is_accepter_started(): # we're done, return the name! return myname else: for possibleport in configuration['ports']: try: servicelogger.log("[INFO]: Trying to wait") shimstack.waitforconn(unique_id, possibleport, nmconnectionmanager.connection_handler) except Exception, e: servicelogger.log("[ERROR]: when calling waitforconn for the connection_handler: " + str(e)) servicelogger.log_last_exception() else: # the waitforconn was completed so the acceptor is started acceptor_state['lock'].acquire() acceptor_state['started']= True acceptor_state['lock'].release() # assign the nodemanager name myname = unique_id + ":" + str(possibleport) servicelogger.log("[INFO]: Now listening as " + myname) break else: servicelogger.log("[ERROR]: cannot find a port for waitforconn.") # check infrequently time.sleep(configuration['pollfrequency'])
477,668
def start_accepter(): shimstack = ShimStackInterface('(NatDeciderShim)') unique_id = rsa_publickey_to_string(configuration['publickey']) unique_id = sha_hexhash(unique_id) + str(configuration['service_vessel']) # do this until we get the accepter started... while True: if is_accepter_started(): # we're done, return the name! return myname else: for possibleport in configuration['ports']: try: servicelogger.log("[INFO]: Trying to wait") shimstack.waitforconn(unique_id, possibleport, nmconnectionmanager.connection_handler) except Exception, e: servicelogger.log("[ERROR]: when calling waitforconn for the connection_handler: " + str(e)) servicelogger.log_last_exception() else: # the waitforconn was completed so the acceptor is started acceptor_state['lock'].acquire() acceptor_state['started']= True acceptor_state['lock'].release() # assign the nodemanager name myname = unique_id + ":" + str(possibleport) servicelogger.log("[INFO]: Now listening as " + myname) break else: servicelogger.log("[ERROR]: cannot find a port for waitforconn.") # check infrequently time.sleep(configuration['pollfrequency'])
def start_accepter(): shimstack = ShimStackInterface('(NatDeciderShim)') unique_id = rsa_publickey_to_string(configuration['publickey']) unique_id = sha_hexhash(unique_id) + str(configuration['service_vessel']) # do this until we get the accepter started... while True: if is_accepter_started(): # we're done, return the name! return myname else: for possibleport in configuration['ports']: try: servicelogger.log("[INFO]: Trying to wait") shimstack.waitforconn(unique_id, possibleport, nmconnectionmanager.connection_handler) except Exception, e: servicelogger.log("[ERROR]: when calling waitforconn for the connection_handler: " + str(e)) servicelogger.log_last_exception() else: # the waitforconn was completed so the acceptor is started accepter_state['lock'].acquire() accepter_state['started']= True accepter_state['lock'].release() # assign the nodemanager name myname = unique_id + ":" + str(possibleport) servicelogger.log("[INFO]: Now listening as " + myname) break else: servicelogger.log("[ERROR]: cannot find a port for waitforconn.") # check infrequently time.sleep(configuration['pollfrequency'])
477,669
def main(): global configuration if not FOREGROUND: # Background ourselves. daemon.daemonize() # ensure that only one instance is running at a time... gotlock = runonce.getprocesslock("seattlenodemanager") if gotlock == True: # I got the lock. All is well... pass else: if gotlock: servicelogger.log("[ERROR]:Another node manager process (pid: " + str(gotlock) + ") is running") else: servicelogger.log("[ERROR]:Another node manager process is running") return # I'll grab the necessary information first... servicelogger.log("[INFO]:Loading config") # BUG: Do this better? Is this the right way to engineer this? configuration = persist.restore_object("nodeman.cfg") # Armon: initialize the network restrictions initialize_ip_interface_restrictions(configuration) # ZACK BOKA: For Linux and Darwin systems, check to make sure that the new # seattle crontab entry has been installed in the crontab. # Do this here because the "nodeman.cfg" needs to have been read # into configuration via the persist module. if nonportable.ostype == 'Linux' or nonportable.ostype == 'Darwin': if 'crontab_updated_for_2009_installer' not in configuration or \ configuration['crontab_updated_for_2009_installer'] == False: try: import update_crontab_entry modified_crontab_entry = \ update_crontab_entry.modify_seattle_crontab_entry() # If updating the seattle crontab entry succeeded, then update the # 'crontab_updated_for_2009_installer' so the nodemanager no longer # tries to update the crontab entry when it starts up. if modified_crontab_entry: configuration['crontab_updated_for_2009_installer'] = True persist.commit_object(configuration,"nodeman.cfg") except Exception,e: exception_traceback_string = traceback.format_exc() servicelogger.log("[ERROR]: The following error occured when " \ + "modifying the crontab for the new 2009 " \ + "seattle crontab entry: " \ + exception_traceback_string) # get the external IP address... # BUG: What if my external IP changes? (A problem throughout) myip = None while True: try: # Try to find our external IP. myip = emulcomm.getmyip() except Exception, e: # If we aren't connected to the internet, emulcomm.getmyip() raises this: if len(e.args) >= 1 and e.args[0] == "Cannot detect a connection to the Internet.": # So we try again. pass else: # It wasn't emulcomm.getmyip()'s exception. re-raise. raise else: # We succeeded in getting our external IP. Leave the loop. break time.sleep(0.1) vesseldict = nmrequesthandler.initialize(myip, configuration['publickey'], version) # Start accepter... myname = start_accepter() #send our advertised name to the log servicelogger.log('myname = '+str(myname)) # Start worker thread... start_worker_thread(configuration['pollfrequency']) # Start advert thread... start_advert_thread(vesseldict, myname, configuration['publickey']) # Start status thread... start_status_thread(vesseldict,configuration['pollfrequency']) # we should be all set up now. servicelogger.log("[INFO]:Started") # I will count my iterations through the loop so that I can log a message # periodically. This makes it clear I am alive. times_through_the_loop = 0 # BUG: Need to exit all when we're being upgraded while True: # E.K Previous there was a check to ensure that the acceptor # thread was started. There is no way to actually check this # and this code was never executed, so i removed it completely if not is_worker_thread_started(): servicelogger.log("[WARN]:At " + str(time.time()) + " restarting worker...") start_worker_thread(configuration['pollfrequency']) if should_start_waitable_thread('advert','Advertisement Thread'): servicelogger.log("[WARN]:At " + str(time.time()) + " restarting advert...") start_advert_thread(vesseldict, myname, configuration['publickey']) if should_start_waitable_thread('status','Status Monitoring Thread'): servicelogger.log("[WARN]:At " + str(time.time()) + " restarting status...") start_status_thread(vesseldict,configuration['pollfrequency']) if not runonce.stillhaveprocesslock("seattlenodemanager"): servicelogger.log("[ERROR]:The node manager lost the process lock...") harshexit.harshexit(55) time.sleep(configuration['pollfrequency']) # if I've been through the loop enough times, log this... times_through_the_loop = times_through_the_loop + 1 if times_through_the_loop % LOG_AFTER_THIS_MANY_ITERATIONS == 0: servicelogger.log("[INFO]: node manager is alive...")
defmain():globalconfigurationifnotFOREGROUND:#Backgroundourselves.daemon.daemonize()#ensurethatonlyoneinstanceisrunningatatime...gotlock=runonce.getprocesslock("seattlenodemanager")ifgotlock==True:#Igotthelock.Alliswell...passelse:ifgotlock:servicelogger.log("[ERROR]:Anothernodemanagerprocess(pid:"+str(gotlock)+")isrunning")else:servicelogger.log("[ERROR]:Anothernodemanagerprocessisrunning")return#I'llgrabthenecessaryinformationfirst...servicelogger.log("[INFO]:Loadingconfig")#BUG:Dothisbetter?Isthistherightwaytoengineerthis?configuration=persist.restore_object("nodeman.cfg")#Armon:initializethenetworkrestrictionsinitialize_ip_interface_restrictions(configuration)#ZACKBOKA:ForLinuxandDarwinsystems,checktomakesurethatthenew#seattlecrontabentryhasbeeninstalledinthecrontab.#Dothisherebecausethe"nodeman.cfg"needstohavebeenread#intoconfigurationviathepersistmodule.ifnonportable.ostype=='Linux'ornonportable.ostype=='Darwin':if'crontab_updated_for_2009_installer'notinconfigurationor\configuration['crontab_updated_for_2009_installer']==False:try:importupdate_crontab_entrymodified_crontab_entry=\update_crontab_entry.modify_seattle_crontab_entry()#Ifupdatingtheseattlecrontabentrysucceeded,thenupdatethe#'crontab_updated_for_2009_installer'sothenodemanagernolonger#triestoupdatethecrontabentrywhenitstartsup.ifmodified_crontab_entry:configuration['crontab_updated_for_2009_installer']=Truepersist.commit_object(configuration,"nodeman.cfg")exceptException,e:exception_traceback_string=traceback.format_exc()servicelogger.log("[ERROR]:Thefollowingerroroccuredwhen"\+"modifyingthecrontabforthenew2009"\+"seattlecrontabentry:"\+exception_traceback_string)#gettheexternalIPaddress...#BUG:WhatifmyexternalIPchanges?(Aproblemthroughout)myip=NonewhileTrue:try:#TrytofindourexternalIP.myip=emulcomm.getmyip()exceptException,e:#Ifwearen'tconnectedtotheinternet,emulcomm.getmyip()raisesthis:iflen(e.args)>=1ande.args[0]=="CannotdetectaconnectiontotheInternet.":#Sowetryagain.passelse:#Itwasn'temulcomm.getmyip()'sexception.re-raise.raiseelse:#WesucceededingettingourexternalIP.Leavetheloop.breaktime.sleep(0.1)vesseldict=nmrequesthandler.initialize(myip,configuration['publickey'],version)#Startaccepter...myname=start_accepter()#sendouradvertisednametothelogservicelogger.log('myname='+str(myname))#Startworkerthread...start_worker_thread(configuration['pollfrequency'])#Startadvertthread...start_advert_thread(vesseldict,myname,configuration['publickey'])#Startstatusthread...start_status_thread(vesseldict,configuration['pollfrequency'])#weshouldbeallsetupnow.servicelogger.log("[INFO]:Started")#IwillcountmyiterationsthroughtheloopsothatIcanlogamessage#periodically.ThismakesitclearIamalive.times_through_the_loop=0#BUG:Needtoexitallwhenwe'rebeingupgradedwhileTrue:#E.KPrevioustherewasachecktoensurethattheacceptor#threadwasstarted.Thereisnowaytoactuallycheckthis#andthiscodewasneverexecuted,soiremoveditcompletelyifnotis_worker_thread_started():servicelogger.log("[WARN]:At"+str(time.time())+"restartingworker...")start_worker_thread(configuration['pollfrequency'])ifshould_start_waitable_thread('advert','AdvertisementThread'):servicelogger.log("[WARN]:At"+str(time.time())+"restartingadvert...")start_advert_thread(vesseldict,myname,configuration['publickey'])ifshould_start_waitable_thread('status','StatusMonitoringThread'):servicelogger.log("[WARN]:At"+str(time.time())+"restartingstatus...")start_status_thread(vesseldict,configuration['pollfrequency'])ifnotrunonce.stillhaveprocesslock("seattlenodemanager"):servicelogger.log("[ERROR]:Thenodemanagerlosttheprocesslock...")harshexit.harshexit(55)time.sleep(configuration['pollfrequency'])#ifI'vebeenthroughtheloopenoughtimes,logthis...times_through_the_loop=times_through_the_loop+1iftimes_through_the_loop%LOG_AFTER_THIS_MANY_ITERATIONS==0:servicelogger.log("[INFO]:nodemanagerisalive...")
477,670
def main(): global configuration if not FOREGROUND: # Background ourselves. daemon.daemonize() # ensure that only one instance is running at a time... gotlock = runonce.getprocesslock("seattlenodemanager") if gotlock == True: # I got the lock. All is well... pass else: if gotlock: servicelogger.log("[ERROR]:Another node manager process (pid: " + str(gotlock) + ") is running") else: servicelogger.log("[ERROR]:Another node manager process is running") return # I'll grab the necessary information first... servicelogger.log("[INFO]:Loading config") # BUG: Do this better? Is this the right way to engineer this? configuration = persist.restore_object("nodeman.cfg") # Armon: initialize the network restrictions initialize_ip_interface_restrictions(configuration) # ZACK BOKA: For Linux and Darwin systems, check to make sure that the new # seattle crontab entry has been installed in the crontab. # Do this here because the "nodeman.cfg" needs to have been read # into configuration via the persist module. if nonportable.ostype == 'Linux' or nonportable.ostype == 'Darwin': if 'crontab_updated_for_2009_installer' not in configuration or \ configuration['crontab_updated_for_2009_installer'] == False: try: import update_crontab_entry modified_crontab_entry = \ update_crontab_entry.modify_seattle_crontab_entry() # If updating the seattle crontab entry succeeded, then update the # 'crontab_updated_for_2009_installer' so the nodemanager no longer # tries to update the crontab entry when it starts up. if modified_crontab_entry: configuration['crontab_updated_for_2009_installer'] = True persist.commit_object(configuration,"nodeman.cfg") except Exception,e: exception_traceback_string = traceback.format_exc() servicelogger.log("[ERROR]: The following error occured when " \ + "modifying the crontab for the new 2009 " \ + "seattle crontab entry: " \ + exception_traceback_string) # get the external IP address... # BUG: What if my external IP changes? (A problem throughout) myip = None while True: try: # Try to find our external IP. myip = emulcomm.getmyip() except Exception, e: # If we aren't connected to the internet, emulcomm.getmyip() raises this: if len(e.args) >= 1 and e.args[0] == "Cannot detect a connection to the Internet.": # So we try again. pass else: # It wasn't emulcomm.getmyip()'s exception. re-raise. raise else: # We succeeded in getting our external IP. Leave the loop. break time.sleep(0.1) vesseldict = nmrequesthandler.initialize(myip, configuration['publickey'], version) # Start accepter... myname = start_accepter() #send our advertised name to the log servicelogger.log('myname = '+str(myname)) # Start worker thread... start_worker_thread(configuration['pollfrequency']) # Start advert thread... start_advert_thread(vesseldict, myname, configuration['publickey']) # Start status thread... start_status_thread(vesseldict,configuration['pollfrequency']) # we should be all set up now. servicelogger.log("[INFO]:Started") # I will count my iterations through the loop so that I can log a message # periodically. This makes it clear I am alive. times_through_the_loop = 0 # BUG: Need to exit all when we're being upgraded while True: # E.K Previous there was a check to ensure that the acceptor # thread was started. There is no way to actually check this # and this code was never executed, so i removed it completely if not is_worker_thread_started(): servicelogger.log("[WARN]:At " + str(time.time()) + " restarting worker...") start_worker_thread(configuration['pollfrequency']) if should_start_waitable_thread('advert','Advertisement Thread'): servicelogger.log("[WARN]:At " + str(time.time()) + " restarting advert...") start_advert_thread(vesseldict, myname, configuration['publickey']) if should_start_waitable_thread('status','Status Monitoring Thread'): servicelogger.log("[WARN]:At " + str(time.time()) + " restarting status...") start_status_thread(vesseldict,configuration['pollfrequency']) if not runonce.stillhaveprocesslock("seattlenodemanager"): servicelogger.log("[ERROR]:The node manager lost the process lock...") harshexit.harshexit(55) time.sleep(configuration['pollfrequency']) # if I've been through the loop enough times, log this... times_through_the_loop = times_through_the_loop + 1 if times_through_the_loop % LOG_AFTER_THIS_MANY_ITERATIONS == 0: servicelogger.log("[INFO]: node manager is alive...")
def main(): global configuration if not FOREGROUND: # Background ourselves. daemon.daemonize() # ensure that only one instance is running at a time... gotlock = runonce.getprocesslock("seattlenodemanager") if gotlock == True: # I got the lock. All is well... pass else: if gotlock: servicelogger.log("[ERROR]:Another node manager process (pid: " + str(gotlock) + ") is running") else: servicelogger.log("[ERROR]:Another node manager process is running") return # I'll grab the necessary information first... servicelogger.log("[INFO]:Loading config") # BUG: Do this better? Is this the right way to engineer this? configuration = persist.restore_object("nodeman.cfg") # Armon: initialize the network restrictions initialize_ip_interface_restrictions(configuration) # ZACK BOKA: For Linux and Darwin systems, check to make sure that the new # seattle crontab entry has been installed in the crontab. # Do this here because the "nodeman.cfg" needs to have been read # into configuration via the persist module. if nonportable.ostype == 'Linux' or nonportable.ostype == 'Darwin': if 'crontab_updated_for_2009_installer' not in configuration or \ configuration['crontab_updated_for_2009_installer'] == False: try: import update_crontab_entry modified_crontab_entry = \ update_crontab_entry.modify_seattle_crontab_entry() # If updating the seattle crontab entry succeeded, then update the # 'crontab_updated_for_2009_installer' so the nodemanager no longer # tries to update the crontab entry when it starts up. if modified_crontab_entry: configuration['crontab_updated_for_2009_installer'] = True persist.commit_object(configuration,"nodeman.cfg") except Exception,e: exception_traceback_string = traceback.format_exc() servicelogger.log("[ERROR]: The following error occured when " \ + "modifying the crontab for the new 2009 " \ + "seattle crontab entry: " \ + exception_traceback_string) # get the external IP address... # BUG: What if my external IP changes? (A problem throughout) myip = None while True: try: # Try to find our external IP. myip = emulcomm.getmyip() except Exception, e: # If we aren't connected to the internet, emulcomm.getmyip() raises this: if len(e.args) >= 1 and e.args[0] == "Cannot detect a connection to the Internet.": # So we try again. pass else: # It wasn't emulcomm.getmyip()'s exception. re-raise. raise else: # We succeeded in getting our external IP. Leave the loop. break time.sleep(0.1) vesseldict = nmrequesthandler.initialize(myip, configuration['publickey'], version) # Start accepter... myname = start_accepter() #send our advertised name to the log servicelogger.log('myname = '+str(myname)) # Start worker thread... start_worker_thread(configuration['pollfrequency']) # Start advert thread... start_advert_thread(vesseldict, myname, configuration['publickey']) # Start status thread... start_status_thread(vesseldict,configuration['pollfrequency']) # we should be all set up now. servicelogger.log("[INFO]:Started") # I will count my iterations through the loop so that I can log a message # periodically. This makes it clear I am alive. times_through_the_loop = 0 # BUG: Need to exit all when we're being upgraded while True: # E.K Previous there was a check to ensure that the acceptor # thread was started. There is no way to actually check this # and this code was never executed, so i removed it completely if not is_worker_thread_started(): servicelogger.log("[WARN]:At " + str(time.time()) + " restarting worker...") start_worker_thread(configuration['pollfrequency']) if should_start_waitable_thread('advert','Advertisement Thread'): servicelogger.log("[WARN]:At " + str(time.time()) + " restarting advert...") start_advert_thread(vesseldict, myname, configuration['publickey']) if should_start_waitable_thread('status','Status Monitoring Thread'): servicelogger.log("[WARN]:At " + str(time.time()) + " restarting status...") start_status_thread(vesseldict,configuration['pollfrequency']) if not runonce.stillhaveprocesslock("seattlenodemanager"): servicelogger.log("[ERROR]:The node manager lost the process lock...") harshexit.harshexit(55) time.sleep(configuration['pollfrequency']) # if I've been through the loop enough times, log this... times_through_the_loop = times_through_the_loop + 1 if times_through_the_loop % LOG_AFTER_THIS_MANY_ITERATIONS == 0: servicelogger.log("[INFO]: node manager is alive...")
477,671
def check_and_exit(): if mycontext['maxlag'] > 4: print "UDP packets lag too long in the buffer: ", mycontext['maxlag'] if mycontext['maxlag'] == 0: print "UDP packets were not received or had 0 lag" exitall()
def check_and_exit(): if mycontext['maxlag'] > 2: print "UDP packets lag too long in the buffer: ", mycontext['maxlag'] if mycontext['maxlag'] == 0: print "UDP packets were not received or had 0 lag" exitall()
477,672
def sendforever(sockobj): while True: # send a message that is around 100 bytes sockobj.send("%9f "%getruntime())
def sendforever(sockobj): while True: # send a message that is around 100 bytes sockobj.send("%9f "%getruntime() + " "*90)
477,673
def handleconnection(ip, port, connobj, ch, mainch): while True: sendtime = float(connobj.recv(10).split()[0]) lag = getruntime() - sendtime if mycontext['maxlag'] < lag: mycontext['maxlag'] = lag
def handleconnection(ip, port, connobj, ch, mainch): while True: sendtime = float(connobj.recv(100).strip().split()[0]) lag = getruntime() - sendtime if mycontext['maxlag'] < lag: mycontext['maxlag'] = lag
477,674
def check_and_exit(): if mycontext['maxlag'] > 4: print "TCP packets lag too long in the buffer: ", mycontext['maxlag'] if mycontext['maxlag'] == 0: print "TCP packets were not received or had 0 lag" exitall()
def check_and_exit(): if mycontext['maxlag'] > 2: print "TCP packets lag too long in the buffer: ", mycontext['maxlag'] if mycontext['maxlag'] == 0: print "TCP packets were not received or had 0 lag" exitall()
477,675
def main(): repytest = False RANDOMPORTS = False target_dir = None for arg in sys.argv[1:]: # -t means we will copy repy tests if arg == '-t': repytest = True # The user wants us to fill in the port numbers randomly. elif arg == '-randomports': RANDOMPORTS = True # Not a flag? Assume it's the target directory else: target_dir = arg # We need a target dir. If one isn't found in argv, quit. if target_dir is None: help_exit("Please pass the target directory as a parameter.") #store root directory current_dir = os.getcwd() # Make sure they gave us a valid directory if not( os.path.isdir(target_dir) ): help_exit("given foldername is not a directory") #set working directory to the test folder os.chdir(target_dir) files_to_remove = glob.glob("*") #clean the test folder for f in files_to_remove: if os.path.isdir(f): shutil.rmtree(f) else: os.remove(f) #go back to root project directory os.chdir(current_dir) #now we copy the necessary files to the test folder copy_to_target("repy/*", target_dir) copy_to_target("nodemanager/*", target_dir) copy_to_target("portability/*", target_dir) copy_to_target("seattlelib/*", target_dir) copy_to_target("seash/*", target_dir) copy_to_target("softwareupdater/*", target_dir) copy_to_target("autograder/nm_remote_api.mix", target_dir) copy_to_target("keydaemon/*", target_dir) # The license must be included in anything we distribute. copy_to_target("LICENSE.TXT", target_dir) # Copy over the files needed for using shim. copy_to_target("production_nat_new/src/nmpatch/nmmain.py", target_dir) copy_to_target("production_nat_new/src/nmpatch/nmclient.repy", target_dir) copy_to_target("production_nat_new/src/nmpatch/sockettimeout.repy", target_dir) copy_to_target("production_nat_new/src/nmpatch/ShimStackInterface.repy", target_dir) # Only copy the tests if they were requested. if repytest: # The test framework itself. copy_to_target("utf/*.py", target_dir) # The various tests. copy_to_target("repy/tests/*", target_dir) copy_to_target("nodemanager/tests/*", target_dir) copy_to_target("portability/tests/*", target_dir) copy_to_target("seash/tests/*", target_dir) copy_to_target("oddball/tests/*", target_dir) copy_to_target("seattlelib/tests/*", target_dir) copy_to_target("keydaemon/tests/*", target_dir) copy_to_target("utf/tests/*", target_dir) # jsamuel: This file, dist/update_crontab_entry.py, is directly included by # make_base_installers and appears to be a candidate for removal someday. # I assume zackrb needed this for installer testing. copy_to_target("dist/update_crontab_entry.py", target_dir) #set working directory to the test folder os.chdir(target_dir) #call the process_mix function to process all mix files in the target directory process_mix("repypp.py") # set up dynamic port information if RANDOMPORTS: portstouseasints = random.sample(range(52000, 53000), 3) portstouseasstr = [] for portint in portstouseasints: portstouseasstr.append(str(portint)) print "Randomly chosen ports: ",portstouseasstr testportfiller.replace_ports(portstouseasstr, portstouseasstr) else: # if this isn't specified, just use the default ports... testportfiller.replace_ports(['12345','12346','12347'], ['12345','12346','12347']) #go back to root project directory os.chdir(current_dir)
def main(): repytest = False RANDOMPORTS = False target_dir = None for arg in sys.argv[1:]: # -t means we will copy repy tests if arg == '-t': repytest = True # The user wants us to fill in the port numbers randomly. elif arg == '-randomports': RANDOMPORTS = True # Not a flag? Assume it's the target directory else: target_dir = arg # We need a target dir. If one isn't found in argv, quit. if target_dir is None: help_exit("Please pass the target directory as a parameter.") #store root directory current_dir = os.getcwd() # Make sure they gave us a valid directory if not( os.path.isdir(target_dir) ): help_exit("given foldername is not a directory") #set working directory to the test folder os.chdir(target_dir) files_to_remove = glob.glob("*") #clean the test folder for f in files_to_remove: if os.path.isdir(f): shutil.rmtree(f) else: os.remove(f) #go back to root project directory os.chdir(current_dir) #now we copy the necessary files to the test folder copy_to_target("repy/*", target_dir) copy_to_target("nodemanager/*", target_dir) copy_to_target("portability/*", target_dir) copy_to_target("seattlelib/*", target_dir) copy_to_target("seash/*", target_dir) copy_to_target("softwareupdater/*", target_dir) copy_to_target("autograder/nm_remote_api.mix", target_dir) copy_to_target("keydaemon/*", target_dir) # The license must be included in anything we distribute. copy_to_target("LICENSE.TXT", target_dir) # Copy over the files needed for using shim. # Only copy the tests if they were requested. if repytest: # The test framework itself. copy_to_target("utf/*.py", target_dir) # The various tests. copy_to_target("repy/tests/*", target_dir) copy_to_target("nodemanager/tests/*", target_dir) copy_to_target("portability/tests/*", target_dir) copy_to_target("seash/tests/*", target_dir) copy_to_target("oddball/tests/*", target_dir) copy_to_target("seattlelib/tests/*", target_dir) copy_to_target("keydaemon/tests/*", target_dir) copy_to_target("utf/tests/*", target_dir) # jsamuel: This file, dist/update_crontab_entry.py, is directly included by # make_base_installers and appears to be a candidate for removal someday. # I assume zackrb needed this for installer testing. copy_to_target("dist/update_crontab_entry.py", target_dir) #set working directory to the test folder os.chdir(target_dir) #call the process_mix function to process all mix files in the target directory process_mix("repypp.py") # set up dynamic port information if RANDOMPORTS: portstouseasints = random.sample(range(52000, 53000), 3) portstouseasstr = [] for portint in portstouseasints: portstouseasstr.append(str(portint)) print "Randomly chosen ports: ",portstouseasstr testportfiller.replace_ports(portstouseasstr, portstouseasstr) else: # if this isn't specified, just use the default ports... testportfiller.replace_ports(['12345','12346','12347'], ['12345','12346','12347']) #go back to root project directory os.chdir(current_dir)
477,676
def start_vessel(vesselhandle, identity, program_file, arg_list=[]): """ <Purpose> Start a program running on a vessel. <Arguments> vesselhandle The vesselhandle of the vessel that is to be started. identity The identity of either the owner or a user of the vessel. program_file The name of the file that already exists on the vessel that is to be run on the vessel. arg_list (optional) A list of arguments to be passed to the program when it is started. <Exceptions> NodeCommunicationError If communication with the node failed, either because the node is down, the communication timed out, the signature was invalid, or the identity unauthorized for this action. <Side Effects> The vessel has been started, running the specified program. <Returns> None """ _validate_vesselhandle(vesselhandle) arg_list.insert(0, program_file) arg_string = " ".join(arg_list) _do_signed_vessel_request(identity, vesselhandle, "StartVessel", arg_string)
def start_vessel(vesselhandle, identity, program_file, arg_list=None): """ <Purpose> Start a program running on a vessel. <Arguments> vesselhandle The vesselhandle of the vessel that is to be started. identity The identity of either the owner or a user of the vessel. program_file The name of the file that already exists on the vessel that is to be run on the vessel. arg_list (optional) A list of arguments to be passed to the program when it is started. <Exceptions> NodeCommunicationError If communication with the node failed, either because the node is down, the communication timed out, the signature was invalid, or the identity unauthorized for this action. <Side Effects> The vessel has been started, running the specified program. <Returns> None """ _validate_vesselhandle(vesselhandle) arg_list.insert(0, program_file) arg_string = " ".join(arg_list) _do_signed_vessel_request(identity, vesselhandle, "StartVessel", arg_string)
477,677
def start_vessel(vesselhandle, identity, program_file, arg_list=[]): """ <Purpose> Start a program running on a vessel. <Arguments> vesselhandle The vesselhandle of the vessel that is to be started. identity The identity of either the owner or a user of the vessel. program_file The name of the file that already exists on the vessel that is to be run on the vessel. arg_list (optional) A list of arguments to be passed to the program when it is started. <Exceptions> NodeCommunicationError If communication with the node failed, either because the node is down, the communication timed out, the signature was invalid, or the identity unauthorized for this action. <Side Effects> The vessel has been started, running the specified program. <Returns> None """ _validate_vesselhandle(vesselhandle) arg_list.insert(0, program_file) arg_string = " ".join(arg_list) _do_signed_vessel_request(identity, vesselhandle, "StartVessel", arg_string)
def start_vessel(vesselhandle, identity, program_file, arg_list=[]): """ <Purpose> Start a program running on a vessel. <Arguments> vesselhandle The vesselhandle of the vessel that is to be started. identity The identity of either the owner or a user of the vessel. program_file The name of the file that already exists on the vessel that is to be run on the vessel. arg_list (optional) A list of arguments to be passed to the program when it is started. <Exceptions> NodeCommunicationError If communication with the node failed, either because the node is down, the communication timed out, the signature was invalid, or the identity unauthorized for this action. <Side Effects> The vessel has been started, running the specified program. <Returns> None """ _validate_vesselhandle(vesselhandle) arg_string = program_file if arg_list is not None: arg_string += " " + " ".join(arg_list) _do_signed_vessel_request(identity, vesselhandle, "StartVessel", arg_string)
477,678
def command_loop(): # Things that may be set herein and used in later commands. # Contains the local variables of the original command loop. # Keeps track of the user's state in seash. Referenced # during command executions by the command_parser. environment_dict = { 'host': None, 'port': None, 'expnum': None, 'filename': None, 'cmdargs': None, 'defaulttarget': None, 'defaultkeyname': None, 'currenttarget': None, 'currentkeyname': None, 'autosave': False, 'handleinfo': {} } # Set up the tab completion environment (Added by Danny Y. Huang) if tabcompletion: completer = TabCompleter() readline.parse_and_bind("tab: complete") readline.set_completer_delims(" ") readline.set_completer(completer.complete) # exit via a return while True: try: # Saving state after each command? (Added by Danny Y. Huang) if environment_dict['autosave'] and environment_dict['defaultkeyname']: try: # State is saved in file "autosave_username", so that user knows which # RSA private key to use to reload the state. autosavefn = "autosave_" + str(environment_dict['defaultkeyname']) seash_helper.savestate(autosavefn, environment_dict['handleinfo'], environment_dict['host'], environment_dict['port'], environment_dict['expnum'], environment_dict['filename'], environment_dict['cmdargs'], environment_dict['defaulttarget'], environment_dict['defaultkeyname'], environment_dict['autosave'], environment_dict['defaultkeyname']) except Exception, error: raise UserError("There is an error in autosave: '" + str(error) + "'. You can turn off autosave using the command 'set autosave off'.") prompt = '' if environment_dict['defaultkeyname']: prompt = seash_helper.fit_string(environment_dict['defaultkeyname'],20)+"@" # display the thing they are acting on in their prompt (if applicable) if environment_dict['defaulttarget']: prompt = prompt + seash_helper.fit_string(environment_dict['defaulttarget'],20) prompt = prompt + " !> " # the prompt should look like: justin@good !> # get the user input userinput = raw_input(prompt) if len(userinput)==0: continue # Returns the dictionary of dictionaries that correspond to the # command the user inputted cmd_input = seash_dictionary.parse_command(userinput) # by default, use the target specified in the prompt environment_dict['currenttarget'] = environment_dict['defaulttarget'] # by default, use the identity specified in the prompt environment_dict['currentkeyname'] = environment_dict['defaultkeyname'] # calls the command_dispatch method of seash_dictionary to execute the callback # method associated with the command the user inputed seash_dictionary.command_dispatch(cmd_input, environment_dict)
def command_loop(): # Things that may be set herein and used in later commands. # Contains the local variables of the original command loop. # Keeps track of the user's state in seash. Referenced # during command executions by the command_parser. environment_dict = { 'host': None, 'port': None, 'expnum': None, 'filename': None, 'cmdargs': None, 'defaulttarget': None, 'defaultkeyname': None, 'currenttarget': None, 'currentkeyname': None, 'autosave': False, 'handleinfo': {} } # Set up the tab completion environment (Added by Danny Y. Huang) if tabcompletion: completer = TabCompleter() readline.parse_and_bind("tab: complete") readline.set_completer_delims(" ") readline.set_completer(completer.complete) # exit via a return while True: try: # Saving state after each command? (Added by Danny Y. Huang) if environment_dict['autosave'] and environment_dict['defaultkeyname']: try: # State is saved in file "autosave_username", so that user knows which # RSA private key to use to reload the state. autosavefn = "autosave_" + str(environment_dict['defaultkeyname']) seash_helper.savestate(autosavefn, environment_dict['handleinfo'], environment_dict['host'], environment_dict['port'], environment_dict['expnum'], environment_dict['filename'], environment_dict['cmdargs'], environment_dict['defaulttarget'], environment_dict['defaultkeyname'], environment_dict['autosave'], environment_dict['defaultkeyname']) except Exception, error: raise seash_exceptions.UserError("There is an error in autosave: '" + str(error) + "'. You can turn off autosave using the command 'set autosave off'.") prompt = '' if environment_dict['defaultkeyname']: prompt = seash_helper.fit_string(environment_dict['defaultkeyname'],20)+"@" # display the thing they are acting on in their prompt (if applicable) if environment_dict['defaulttarget']: prompt = prompt + seash_helper.fit_string(environment_dict['defaulttarget'],20) prompt = prompt + " !> " # the prompt should look like: justin@good !> # get the user input userinput = raw_input(prompt) if len(userinput)==0: continue # Returns the dictionary of dictionaries that correspond to the # command the user inputted cmd_input = seash_dictionary.parse_command(userinput) # by default, use the target specified in the prompt environment_dict['currenttarget'] = environment_dict['defaulttarget'] # by default, use the identity specified in the prompt environment_dict['currentkeyname'] = environment_dict['defaultkeyname'] # calls the command_dispatch method of seash_dictionary to execute the callback # method associated with the command the user inputed seash_dictionary.command_dispatch(cmd_input, environment_dict)
477,679
def test_module(module_name, module_file_list): """ <Purpose> Execute all test files contained within module_file_list matching the module_name in the form of each test file name 'ut_<module_name>_<descriptor>.py' <Arguments> module_name: module name to be tested module_file_list: a list of files to be filtered by module name and ran through the testing framework <Exceptions> None <Side Effects> None <Returns> None """ print 'Testing module:', module_name setup_file = None # Given all test files for the specified module name, find the file whose # descriptor equals 'setup' (there can be only one such file name). filtered_files = filter_files(module_file_list, descriptor = 'setup') if filtered_files: setup_file = filtered_files.pop() module_file_list.remove(setup_file) subprocess_file = None filtered_files = filter_files(module_file_list, descriptor = 'subprocess') if filtered_files: subprocess_file = filtered_files.pop() module_file_list.remove(subprocess_file) shutdown_file = None # Given all test files for the specified module name, find the file whose # descriptor equals 'shutdown' (there can be only one such file name). filtered_files = filter_files(module_file_list, descriptor = 'shutdown') if filtered_files: shutdown_file = filtered_files.pop() module_file_list.remove(shutdown_file) sub = None # If we must open a process to run on the side of if subprocess_file: print "Now starting subprocess: " + subprocess_file sub = subprocess.Popen(['python', subprocess_file]) time.sleep(10) if setup_file: print "Now running setup script: " + setup_file test_single(setup_file) for test_file in module_file_list: test_single(test_file) if shutdown_file: print "Now running shutdown script: " + shutdown_file test_single(shutdown_file) #If we opened a subprocess, we need to be sure to kill it if sub: print "Now killing subprocess: " + subprocess_file if sys.version_info < (2, 6): os.kill(sub.pid, signal.SIGTERM) else: sub.kill()
def test_module(module_name, module_file_list): """ <Purpose> Execute all test files contained within module_file_list matching the module_name in the form of each test file name 'ut_<module_name>_<descriptor>.py' <Arguments> module_name: module name to be tested module_file_list: a list of files to be filtered by module name and ran through the testing framework <Exceptions> None <Side Effects> None <Returns> None """ print 'Testing module:', module_name setup_file = None # Given all test files for the specified module name, find the file whose # descriptor equals 'setup' (there can be only one such file name). filtered_files = filter_files(module_file_list, descriptor = 'setup') if filtered_files: setup_file = filtered_files.pop() module_file_list.remove(setup_file) subprocess_file = None filtered_files = filter_files(module_file_list, descriptor = 'subprocess') if filtered_files: subprocess_file = filtered_files.pop() module_file_list.remove(subprocess_file) shutdown_file = None # Given all test files for the specified module name, find the file whose # descriptor equals 'shutdown' (there can be only one such file name). filtered_files = filter_files(module_file_list, descriptor = 'shutdown') if filtered_files: shutdown_file = filtered_files.pop() module_file_list.remove(shutdown_file) sub = None # If we must open a process to run on the side of if subprocess_file: print "Now starting subprocess: " + subprocess_file sub = subprocess.Popen(['python', subprocess_file]) time.sleep(10) if setup_file: print "Now running setup script: " + setup_file test_single(setup_file) for test_file in module_file_list: test_single(test_file) if shutdown_file: print "Now running shutdown script: " + shutdown_file test_single(shutdown_file) #If we opened a subprocess, we need to be sure to kill it if sub: print "Now killing subprocess: " + subprocess_file if sys.version_info < (2, 6): os.kill(sub.pid, signal.SIGTERM) else: sub.kill()
477,680
def test_module(module_name, module_file_list): """ <Purpose> Execute all test files contained within module_file_list matching the module_name in the form of each test file name 'ut_<module_name>_<descriptor>.py' <Arguments> module_name: module name to be tested module_file_list: a list of files to be filtered by module name and ran through the testing framework <Exceptions> None <Side Effects> None <Returns> None """ print 'Testing module:', module_name setup_file = None # Given all test files for the specified module name, find the file whose # descriptor equals 'setup' (there can be only one such file name). filtered_files = filter_files(module_file_list, descriptor = 'setup') if filtered_files: setup_file = filtered_files.pop() module_file_list.remove(setup_file) subprocess_file = None filtered_files = filter_files(module_file_list, descriptor = 'subprocess') if filtered_files: subprocess_file = filtered_files.pop() module_file_list.remove(subprocess_file) shutdown_file = None # Given all test files for the specified module name, find the file whose # descriptor equals 'shutdown' (there can be only one such file name). filtered_files = filter_files(module_file_list, descriptor = 'shutdown') if filtered_files: shutdown_file = filtered_files.pop() module_file_list.remove(shutdown_file) sub = None # If we must open a process to run on the side of if subprocess_file: print "Now starting subprocess: " + subprocess_file sub = subprocess.Popen(['python', subprocess_file]) time.sleep(10) if setup_file: print "Now running setup script: " + setup_file test_single(setup_file) for test_file in module_file_list: test_single(test_file) if shutdown_file: print "Now running shutdown script: " + shutdown_file test_single(shutdown_file) #If we opened a subprocess, we need to be sure to kill it if sub: print "Now killing subprocess: " + subprocess_file if sys.version_info < (2, 6): os.kill(sub.pid, signal.SIGTERM) else: sub.kill()
def test_module(module_name, module_file_list): """ <Purpose> Execute all test files contained within module_file_list matching the module_name in the form of each test file name 'ut_<module_name>_<descriptor>.py' <Arguments> module_name: module name to be tested module_file_list: a list of files to be filtered by module name and ran through the testing framework <Exceptions> None <Side Effects> None <Returns> None """ print 'Testing module:', module_name setup_file = None # Given all test files for the specified module name, find the file whose # descriptor equals 'setup' (there can be only one such file name). filtered_files = filter_files(module_file_list, descriptor = 'setup') if filtered_files: setup_file = filtered_files.pop() module_file_list.remove(setup_file) subprocess_file = None filtered_files = filter_files(module_file_list, descriptor = 'subprocess') if filtered_files: subprocess_file = filtered_files.pop() module_file_list.remove(subprocess_file) shutdown_file = None # Given all test files for the specified module name, find the file whose # descriptor equals 'shutdown' (there can be only one such file name). filtered_files = filter_files(module_file_list, descriptor = 'shutdown') if filtered_files: shutdown_file = filtered_files.pop() module_file_list.remove(shutdown_file) sub = None # If we must open a process to run on the side of if subprocess_file: print "Now starting subprocess: " + subprocess_file sub = subprocess.Popen(['python', subprocess_file]) time.sleep(30) if setup_file: print "Now running setup script: " + setup_file test_single(setup_file) for test_file in module_file_list: test_single(test_file) if shutdown_file: print "Now running shutdown script: " + shutdown_file test_single(shutdown_file) #If we opened a subprocess, we need to be sure to kill it if sub: print "Now killing subprocess: " + subprocess_file if sys.version_info < (2, 6): os.kill(sub.pid, signal.SIGTERM) else: sub.kill()
477,681
def set_keys(vessel, identity): """ The first argument will be a vesseldict rather than a vesselhandle because we passed the result of get_vessels_on_nodes to run_parallelized. """ if vessel['vesselname'] != VESSELNAME_TO_SET_USER_KEYS_ON: msg = "[" + vessel['location'] + "] Skipping: vesselname is not: " + VESSELNAME_TO_SET_USER_KEYS_ON print(msg) raise Exception(msg) if vessel['userkeys'] != USERKEY_LIST: print("[" + vessel['location'] + "] Setting user keys.") try: experimentlib.set_vessel_users(vessel['handle'], identity, USERKEY_LIST) except Exception, e: msg = "[" + vessel['location'] + "] Failure: " + str(e) print(msg) import traceback traceback.print_exc() raise Exception(msg) else: print("[" + vessel['location'] + "] Success.") else: print("[" + vessel['location'] + "] Already had correct user keys.")
def set_keys(vessel, identity): """ The first argument will be a vesseldict rather than a vesselhandle because we passed the result of get_vessels_on_nodes to run_parallelized. """ if vessel['vesselname'] != VESSELNAME_TO_SET_USER_KEYS_ON: msg = "[" + vessel['nodelocation'] + "] Skipping: vesselname is not: " + VESSELNAME_TO_SET_USER_KEYS_ON print(msg) raise Exception(msg) if vessel['userkeys'] != USERKEY_LIST: print("[" + vessel['location'] + "] Setting user keys.") try: experimentlib.set_vessel_users(vessel['handle'], identity, USERKEY_LIST) except Exception, e: msg = "[" + vessel['location'] + "] Failure: " + str(e) print(msg) import traceback traceback.print_exc() raise Exception(msg) else: print("[" + vessel['location'] + "] Success.") else: print("[" + vessel['location'] + "] Already had correct user keys.")
477,682
def set_keys(vessel, identity): """ The first argument will be a vesseldict rather than a vesselhandle because we passed the result of get_vessels_on_nodes to run_parallelized. """ if vessel['vesselname'] != VESSELNAME_TO_SET_USER_KEYS_ON: msg = "[" + vessel['location'] + "] Skipping: vesselname is not: " + VESSELNAME_TO_SET_USER_KEYS_ON print(msg) raise Exception(msg) if vessel['userkeys'] != USERKEY_LIST: print("[" + vessel['location'] + "] Setting user keys.") try: experimentlib.set_vessel_users(vessel['handle'], identity, USERKEY_LIST) except Exception, e: msg = "[" + vessel['location'] + "] Failure: " + str(e) print(msg) import traceback traceback.print_exc() raise Exception(msg) else: print("[" + vessel['location'] + "] Success.") else: print("[" + vessel['location'] + "] Already had correct user keys.")
def set_keys(vessel, identity): """ The first argument will be a vesseldict rather than a vesselhandle because we passed the result of get_vessels_on_nodes to run_parallelized. """ if vessel['vesselname'] != VESSELNAME_TO_SET_USER_KEYS_ON: msg = "[" + vessel['location'] + "] Skipping: vesselname is not: " + VESSELNAME_TO_SET_USER_KEYS_ON print(msg) raise Exception(msg) if vessel['userkeys'] != USERKEY_LIST: print("[" + vessel['nodelocation'] + "] Setting user keys.") try: experimentlib.set_vessel_users(vessel['handle'], identity, USERKEY_LIST) except Exception, e: msg = "[" + vessel['location'] + "] Failure: " + str(e) print(msg) import traceback traceback.print_exc() raise Exception(msg) else: print("[" + vessel['location'] + "] Success.") else: print("[" + vessel['location'] + "] Already had correct user keys.")
477,683
def set_keys(vessel, identity): """ The first argument will be a vesseldict rather than a vesselhandle because we passed the result of get_vessels_on_nodes to run_parallelized. """ if vessel['vesselname'] != VESSELNAME_TO_SET_USER_KEYS_ON: msg = "[" + vessel['location'] + "] Skipping: vesselname is not: " + VESSELNAME_TO_SET_USER_KEYS_ON print(msg) raise Exception(msg) if vessel['userkeys'] != USERKEY_LIST: print("[" + vessel['location'] + "] Setting user keys.") try: experimentlib.set_vessel_users(vessel['handle'], identity, USERKEY_LIST) except Exception, e: msg = "[" + vessel['location'] + "] Failure: " + str(e) print(msg) import traceback traceback.print_exc() raise Exception(msg) else: print("[" + vessel['location'] + "] Success.") else: print("[" + vessel['location'] + "] Already had correct user keys.")
def set_keys(vessel, identity): """ The first argument will be a vesseldict rather than a vesselhandle because we passed the result of get_vessels_on_nodes to run_parallelized. """ if vessel['vesselname'] != VESSELNAME_TO_SET_USER_KEYS_ON: msg = "[" + vessel['location'] + "] Skipping: vesselname is not: " + VESSELNAME_TO_SET_USER_KEYS_ON print(msg) raise Exception(msg) if vessel['userkeys'] != USERKEY_LIST: print("[" + vessel['location'] + "] Setting user keys.") try: experimentlib.set_vessel_users(vessel['vesselhandle'], identity, USERKEY_LIST) except Exception, e: msg = "[" + vessel['location'] + "] Failure: " + str(e) print(msg) import traceback traceback.print_exc() raise Exception(msg) else: print("[" + vessel['location'] + "] Success.") else: print("[" + vessel['location'] + "] Already had correct user keys.")
477,684
def set_keys(vessel, identity): """ The first argument will be a vesseldict rather than a vesselhandle because we passed the result of get_vessels_on_nodes to run_parallelized. """ if vessel['vesselname'] != VESSELNAME_TO_SET_USER_KEYS_ON: msg = "[" + vessel['location'] + "] Skipping: vesselname is not: " + VESSELNAME_TO_SET_USER_KEYS_ON print(msg) raise Exception(msg) if vessel['userkeys'] != USERKEY_LIST: print("[" + vessel['location'] + "] Setting user keys.") try: experimentlib.set_vessel_users(vessel['handle'], identity, USERKEY_LIST) except Exception, e: msg = "[" + vessel['location'] + "] Failure: " + str(e) print(msg) import traceback traceback.print_exc() raise Exception(msg) else: print("[" + vessel['location'] + "] Success.") else: print("[" + vessel['location'] + "] Already had correct user keys.")
def set_keys(vessel, identity): """ The first argument will be a vesseldict rather than a vesselhandle because we passed the result of get_vessels_on_nodes to run_parallelized. """ if vessel['vesselname'] != VESSELNAME_TO_SET_USER_KEYS_ON: msg = "[" + vessel['location'] + "] Skipping: vesselname is not: " + VESSELNAME_TO_SET_USER_KEYS_ON print(msg) raise Exception(msg) if vessel['userkeys'] != USERKEY_LIST: print("[" + vessel['location'] + "] Setting user keys.") try: experimentlib.set_vessel_users(vessel['handle'], identity, USERKEY_LIST) except Exception, e: msg = "[" + vessel['nodelocation'] + "] Failure: " + str(e) print(msg) import traceback traceback.print_exc() raise Exception(msg) else: print("[" + vessel['location'] + "] Success.") else: print("[" + vessel['location'] + "] Already had correct user keys.")
477,685
def set_keys(vessel, identity): """ The first argument will be a vesseldict rather than a vesselhandle because we passed the result of get_vessels_on_nodes to run_parallelized. """ if vessel['vesselname'] != VESSELNAME_TO_SET_USER_KEYS_ON: msg = "[" + vessel['location'] + "] Skipping: vesselname is not: " + VESSELNAME_TO_SET_USER_KEYS_ON print(msg) raise Exception(msg) if vessel['userkeys'] != USERKEY_LIST: print("[" + vessel['location'] + "] Setting user keys.") try: experimentlib.set_vessel_users(vessel['handle'], identity, USERKEY_LIST) except Exception, e: msg = "[" + vessel['location'] + "] Failure: " + str(e) print(msg) import traceback traceback.print_exc() raise Exception(msg) else: print("[" + vessel['location'] + "] Success.") else: print("[" + vessel['location'] + "] Already had correct user keys.")
def set_keys(vessel, identity): """ The first argument will be a vesseldict rather than a vesselhandle because we passed the result of get_vessels_on_nodes to run_parallelized. """ if vessel['vesselname'] != VESSELNAME_TO_SET_USER_KEYS_ON: msg = "[" + vessel['location'] + "] Skipping: vesselname is not: " + VESSELNAME_TO_SET_USER_KEYS_ON print(msg) raise Exception(msg) if vessel['userkeys'] != USERKEY_LIST: print("[" + vessel['location'] + "] Setting user keys.") try: experimentlib.set_vessel_users(vessel['handle'], identity, USERKEY_LIST) except Exception, e: msg = "[" + vessel['location'] + "] Failure: " + str(e) print(msg) import traceback traceback.print_exc() raise Exception(msg) else: print("[" + vessel['nodelocation'] + "] Success.") else: print("[" + vessel['location'] + "] Already had correct user keys.")
477,686
def set_keys(vessel, identity): """ The first argument will be a vesseldict rather than a vesselhandle because we passed the result of get_vessels_on_nodes to run_parallelized. """ if vessel['vesselname'] != VESSELNAME_TO_SET_USER_KEYS_ON: msg = "[" + vessel['location'] + "] Skipping: vesselname is not: " + VESSELNAME_TO_SET_USER_KEYS_ON print(msg) raise Exception(msg) if vessel['userkeys'] != USERKEY_LIST: print("[" + vessel['location'] + "] Setting user keys.") try: experimentlib.set_vessel_users(vessel['handle'], identity, USERKEY_LIST) except Exception, e: msg = "[" + vessel['location'] + "] Failure: " + str(e) print(msg) import traceback traceback.print_exc() raise Exception(msg) else: print("[" + vessel['location'] + "] Success.") else: print("[" + vessel['location'] + "] Already had correct user keys.")
def set_keys(vessel, identity): """ The first argument will be a vesseldict rather than a vesselhandle because we passed the result of get_vessels_on_nodes to run_parallelized. """ if vessel['vesselname'] != VESSELNAME_TO_SET_USER_KEYS_ON: msg = "[" + vessel['location'] + "] Skipping: vesselname is not: " + VESSELNAME_TO_SET_USER_KEYS_ON print(msg) raise Exception(msg) if vessel['userkeys'] != USERKEY_LIST: print("[" + vessel['location'] + "] Setting user keys.") try: experimentlib.set_vessel_users(vessel['handle'], identity, USERKEY_LIST) except Exception, e: msg = "[" + vessel['location'] + "] Failure: " + str(e) print(msg) import traceback traceback.print_exc() raise Exception(msg) else: print("[" + vessel['location'] + "] Success.") else: print("[" + vessel['nodelocation'] + "] Already had correct user keys.")
477,687
def _translation_is_needed(repyfilename, generatedfile): """ Checks if generatedfile needs to be regenerated. Does several checks to decide if generating generatedfilename based on repyfilename is a good idea. --does file already exist? --was it automatically generated? --was it generated from the same source file? --was the original modified since the last translation? """ if not os.path.isfile(repyfilename): raise TranslationError("no such file:", repyfilename) if not os.path.isfile(generatedfile): return True #Read the first line try: fh = open(generatedfile, "r") first_line = fh.readline().rstrip() current_line = '' for line in fh: current_line = line last_line = current_line fh.close() except IOError, e: raise TranslationError("Error opening old generated file: " + generatedfile + ": " + str(e)) #Check to see if the file was generated by repyhelper, to prevent #clobbering a file that we didn't create if not first_line.startswith(TRANSLATION_TAGLINE): raise TranslationError("File name exists but wasn't automatically generated: " + generatedfile) if not last_line.startswith(TRANSLATION_TAGLINE): # The file generation wasn't completed... I think this means we should # silently regenerate (#617) return True #Check to see if the generated file has the same original source old_translation_path = first_line[len(TRANSLATION_TAGLINE):].strip() generated_abs_path = os.path.abspath(repyfilename) if old_translation_path != generated_abs_path: #It doesn't match, but the other file was also a translation! Regen then... return True #If we get here and modification time of orig is older than gen, this is still #a valid generation repystat = os.stat(repyfilename) genstat = os.stat(generatedfile) if repystat.st_mtime < genstat.st_mtime: return False return True
def _translation_is_needed(repyfilename, generatedfile): """ Checks if generatedfile needs to be regenerated. Does several checks to decide if generating generatedfilename based on repyfilename is a good idea. --does file already exist? --was it automatically generated? --was it generated from the same source file? --was the original modified since the last translation? """ if not os.path.isfile(repyfilename): raise TranslationError("no such file:", repyfilename) if not os.path.isfile(generatedfile): return True #Read the first line try: fh = open(generatedfile, "r") first_line = fh.readline().rstrip() current_line = '' for line in fh: current_line = line last_line = current_line fh.close() except IOError, e: raise TranslationError("Error opening old generated file: " + generatedfile + ": " + str(e)) #Check to see if the file was generated by repyhelper, to prevent #clobbering a file that we didn't create if not first_line.startswith(ENCODING_STRING) or not second_line.startswith(TRANSLATION_TAGLINE): raise TranslationError("File name exists but wasn't automatically generated: " + generatedfile) if not last_line.startswith(TRANSLATION_TAGLINE): # The file generation wasn't completed... I think this means we should # silently regenerate (#617) return True #Check to see if the generated file has the same original source old_translation_path = first_line[len(TRANSLATION_TAGLINE):].strip() generated_abs_path = os.path.abspath(repyfilename) if old_translation_path != generated_abs_path: #It doesn't match, but the other file was also a translation! Regen then... return True #If we get here and modification time of orig is older than gen, this is still #a valid generation repystat = os.stat(repyfilename) genstat = os.stat(generatedfile) if repystat.st_mtime < genstat.st_mtime: return False return True
477,688
def start_event(entry, handle,eventhandle): if entry['type'] == 'UDP': # some sort of socket error, I'll assume they closed the socket or it's # not important try: # NOTE: is 4096 a reasonable maximum datagram size? data, addr = entry['socket'].recvfrom(4096) except socket.error: # they closed in the meantime? nanny.tattle_remove_item('events',eventhandle) return # wait if we're over the limit if data: if is_loopback(entry['localip']): nanny.tattle_quantity('looprecv',len(data)) else: nanny.tattle_quantity('netrecv',len(data)) else: # no data... Let's stop this... nanny.tattle_remove_item('events',eventhandle) return try: EventDeliverer(entry['function'],(addr[0], addr[1], data, handle), eventhandle).start() except: # This is an internal error I think... # This will cause the program to exit and log things if logging is # enabled. -Brent tracebackrepy.handle_internalerror("Can't start UDP EventDeliverer", 29) # or it's a TCP accept event... elif entry['type'] == 'TCP': try: realsocket, addr = entry['socket'].accept() except socket.error: # they closed in the meantime? nanny.tattle_remove_item('events',eventhandle) return # put this handle in the table newhandle = generate_commhandle() comminfo[newhandle] = {'type':'TCP','remotehost':addr[0], 'remoteport':addr[1],'localip':entry['localip'],'localport':entry['localport'],'socket':realsocket,'outgoing':True, 'closing_lock':threading.Lock()} # I don't think it makes sense to count this as an outgoing socket, does # it? # Armon: Create the emulated socket after the table entry safesocket = emulated_socket(newhandle) try: EventDeliverer(entry['function'],(addr[0], addr[1], safesocket, newhandle, handle),eventhandle).start() except: # This is an internal error I think... # This will cause the program to exit and log things if logging is # enabled. -Brent tracebackrepy.handle_internalerror("Can't start TCP EventDeliverer", 23) else: # Should never get here # This will cause the program to exit and log things if logging is # enabled. -Brent tracebackrepy.handle_internalerror("In start event, Unknown entry type", 51)
def start_event(entry, handle,eventhandle): if entry['type'] == 'UDP': # some sort of socket error, I'll assume they closed the socket or it's # not important try: # NOTE: is 4096 a reasonable maximum datagram size? data, addr = entry['socket'].recvfrom(65535) except socket.error: # they closed in the meantime? nanny.tattle_remove_item('events',eventhandle) return # wait if we're over the limit if data: if is_loopback(entry['localip']): nanny.tattle_quantity('looprecv',len(data)) else: nanny.tattle_quantity('netrecv',len(data)) else: # no data... Let's stop this... nanny.tattle_remove_item('events',eventhandle) return try: EventDeliverer(entry['function'],(addr[0], addr[1], data, handle), eventhandle).start() except: # This is an internal error I think... # This will cause the program to exit and log things if logging is # enabled. -Brent tracebackrepy.handle_internalerror("Can't start UDP EventDeliverer", 29) # or it's a TCP accept event... elif entry['type'] == 'TCP': try: realsocket, addr = entry['socket'].accept() except socket.error: # they closed in the meantime? nanny.tattle_remove_item('events',eventhandle) return # put this handle in the table newhandle = generate_commhandle() comminfo[newhandle] = {'type':'TCP','remotehost':addr[0], 'remoteport':addr[1],'localip':entry['localip'],'localport':entry['localport'],'socket':realsocket,'outgoing':True, 'closing_lock':threading.Lock()} # I don't think it makes sense to count this as an outgoing socket, does # it? # Armon: Create the emulated socket after the table entry safesocket = emulated_socket(newhandle) try: EventDeliverer(entry['function'],(addr[0], addr[1], safesocket, newhandle, handle),eventhandle).start() except: # This is an internal error I think... # This will cause the program to exit and log things if logging is # enabled. -Brent tracebackrepy.handle_internalerror("Can't start TCP EventDeliverer", 23) else: # Should never get here # This will cause the program to exit and log things if logging is # enabled. -Brent tracebackrepy.handle_internalerror("In start event, Unknown entry type", 51)
477,689
def _translation_is_needed(repyfilename, generatedfile): """ Checks if generatedfile needs to be regenerated. Does several checks to decide if generating generatedfilename based on repyfilename is a good idea. --does file already exist? --was it automatically generated? --was it generated from the same source file? --was the original modified since the last translation? """ if not os.path.isfile(repyfilename): raise TranslationError("no such file:", repyfilename) if not os.path.isfile(generatedfile): return True #Read the first line try: fh = open(generatedfile, "r") first_line = fh.readline().rstrip() second_line = fh.readline().rstrip() current_line = '' for line in fh: current_line = line last_line = current_line fh.close() except IOError, e: raise TranslationError("Error opening old generated file: " + generatedfile + ": " + str(e)) #Check to see if the file was generated by repyhelper, to prevent #clobbering a file that we didn't create if not first_line.startswith(ENCODING_STRING) or not second_line.startswith(TRANSLATION_TAGLINE): raise TranslationError("File name exists but wasn't automatically generated: " + generatedfile) if not last_line.startswith(TRANSLATION_TAGLINE): # The file generation wasn't completed... I think this means we should # silently regenerate (#617) return True #Check to see if the generated file has the same original source old_translation_path = first_line[len(TRANSLATION_TAGLINE):].strip() generated_abs_path = os.path.abspath(repyfilename) if old_translation_path != generated_abs_path: #It doesn't match, but the other file was also a translation! Regen then... return True #If we get here and modification time of orig is older than gen, this is still #a valid generation repystat = os.stat(repyfilename) genstat = os.stat(generatedfile) if repystat.st_mtime < genstat.st_mtime: return False return True
def _translation_is_needed(repyfilename, generatedfile): """ Checks if generatedfile needs to be regenerated. Does several checks to decide if generating generatedfilename based on repyfilename is a good idea. --does file already exist? --was it automatically generated? --was it generated from the same source file? --was the original modified since the last translation? """ if not os.path.isfile(repyfilename): raise TranslationError("no such file:", repyfilename) if not os.path.isfile(generatedfile): return True #Read the first line try: fh = open(generatedfile, "r") first_line = fh.readline().rstrip() second_line = fh.readline().rstrip() current_line = '' for line in fh: current_line = line last_line = current_line fh.close() except IOError, e: raise TranslationError("Error opening old generated file: " + generatedfile + ": " + str(e)) #Check to see if the file was generated by repyhelper, to prevent #clobbering a file that we didn't create if not first_line.startswith(ENCODING_STRING) or not second_line.startswith(TRANSLATION_TAGLINE): if not first_line.startswith(TRANSLATION_TAGLINE): raise TranslationError("File name exists but wasn't automatically generated: " + generatedfile) if not last_line.startswith(TRANSLATION_TAGLINE): # The file generation wasn't completed... I think this means we should # silently regenerate (#617) return True #Check to see if the generated file has the same original source old_translation_path = first_line[len(TRANSLATION_TAGLINE):].strip() generated_abs_path = os.path.abspath(repyfilename) if old_translation_path != generated_abs_path: #It doesn't match, but the other file was also a translation! Regen then... return True #If we get here and modification time of orig is older than gen, this is still #a valid generation repystat = os.stat(repyfilename) genstat = os.stat(generatedfile) if repystat.st_mtime < genstat.st_mtime: return False return True
477,690
def commit_time(thread_dict, TOC): resource = thread_dict["resource"] thread_dict[resource] += TOC - thread_dict["begin"] thread_dict["begin"] = TOC
def commit_time(thread_dict, TOC): resource = thread_dict["resource"] thread_dict[resource] += TOC - thread_dict["begin"] thread_dict["begin"] = TOC
477,691
def commit_time(thread_dict, TOC): resource = thread_dict["resource"] thread_dict[resource] += TOC - thread_dict["begin"] thread_dict["begin"] = TOC
def commit_time(thread_dict, TOC): resource = thread_dict["resource"] thread_dict[resource] += TOC - thread_dict["begin"] thread_dict["begin"] = TOC
477,692
def commit_time(thread_dict, TOC): resource = thread_dict["resource"] thread_dict[resource] += TOC - thread_dict["begin"] thread_dict["begin"] = TOC
def commit_time(thread_dict, TOC): resource = thread_dict["resource"] thread_dict[resource] += TOC - thread_dict["begin"] thread_dict["begin"] = TOC
477,693
def exec_repy_script(filename, restrictionsfile, arguments={}, script_args=''): global mobileNoSubprocess if script_args != '': script_args = ' ' + script_args if not mobileNoSubprocess: # Convert arguments arg_string = arguments_to_string(arguments) return exec_command('python repy.py ' + arg_string + restrictionsfile + ' ' + filename + script_args) else: if os.path.isfile(repy_constants.PATH_SEATTLE_INSTALL + "execlog.out.old"): os.remove(repy_constants.PATH_SEATTLE_INSTALL + "execlog.out.old") if os.path.isfile(repy_constants.PATH_SEATTLE_INSTALL + "execlog.out.new"): os.remove(repy_constants.PATH_SEATTLE_INSTALL + "execlog.out.new") # Set default values arguments.setdefault("logfile", "execlog.out") arguments.setdefault("cwd", "\"" + repy_constants.PATH_SEATTLE_INSTALL + "\"") # Convert arguments arg_string = arguments_to_string(arguments) repy_path = "\"" + repy_constants.PATH_SEATTLE_INSTALL + "repy.py" + "\"" cmd = arg_string + restrictionsfile + " \"" + repy_constants.PATH_SEATTLE_INSTALL + filename + "\"" + script_args #print cmd childpid = windowsAPI.launchPythonScript(repy_path, cmd) # Wait for Child to finish execution windowsAPI.waitForProcess(childpid) time.sleep(5) if os.path.isfile(repy_constants.PATH_SEATTLE_INSTALL + "execlog.out.old"): theout = file(repy_constants.PATH_SEATTLE_INSTALL + "execlog.out.old", "r") output = theout.read() theout.close() else: output = '' return (output, '')
def exec_repy_script(filename, restrictionsfile, arguments=None, script_args=''): global mobileNoSubprocess if script_args != '': script_args = ' ' + script_args if not mobileNoSubprocess: # Convert arguments arg_string = arguments_to_string(arguments) return exec_command('python repy.py ' + arg_string + restrictionsfile + ' ' + filename + script_args) else: if os.path.isfile(repy_constants.PATH_SEATTLE_INSTALL + "execlog.out.old"): os.remove(repy_constants.PATH_SEATTLE_INSTALL + "execlog.out.old") if os.path.isfile(repy_constants.PATH_SEATTLE_INSTALL + "execlog.out.new"): os.remove(repy_constants.PATH_SEATTLE_INSTALL + "execlog.out.new") # Set default values arguments.setdefault("logfile", "execlog.out") arguments.setdefault("cwd", "\"" + repy_constants.PATH_SEATTLE_INSTALL + "\"") # Convert arguments arg_string = arguments_to_string(arguments) repy_path = "\"" + repy_constants.PATH_SEATTLE_INSTALL + "repy.py" + "\"" cmd = arg_string + restrictionsfile + " \"" + repy_constants.PATH_SEATTLE_INSTALL + filename + "\"" + script_args #print cmd childpid = windowsAPI.launchPythonScript(repy_path, cmd) # Wait for Child to finish execution windowsAPI.waitForProcess(childpid) time.sleep(5) if os.path.isfile(repy_constants.PATH_SEATTLE_INSTALL + "execlog.out.old"): theout = file(repy_constants.PATH_SEATTLE_INSTALL + "execlog.out.old", "r") output = theout.read() theout.close() else: output = '' return (output, '')
477,694
def main(): if OS not in SUPPORTED_OSES: raise UnsupportedOSError("This operating system is not supported.") # Begin pre-installation process. # Pre-install: parse the passed-in arguments. try: # Armon: Changed getopt to accept parameters for Repy and NM IP/Iface # restrictions, also a special disable flag opts, args = getopt.getopt(sys.argv[1:], "s", ["percent=", "nm-key-bitsize=","nm-ip=", "nm-iface=","repy-ip=","repy-iface=", "repy-nootherips","onlynetwork", "disable-startup-script","usage"]) except getopt.GetoptError, err: print str(err) usage() return # Derek Cheng: if the user is running a Nokia N800 tablet, we require them # to be on root first in order to have files created in the /etc/init.d and # /etc/rc2.d directories. if platform.machine().startswith('armv'): _output('Seattle is being installed on a Nokia N800/900 Internet Tablet.') # JAC: I can't import this on Windows, so will do it here... import pwd # if the current user name is not 'root' if pwd.getpwuid(os.getuid())[0] != 'root': _output('Please run the installer as root. This can be done by ' \ + 'installing/using the rootsh or openssh package.') return # Pre-install: process the passed-in arguments, and set up the configuration # dictionary. continue_install = prepare_installation(opts,args) if not continue_install: return # Pre-install: run all tests and benchmarking. # test_urandom_implemented() MUST be performed before # perform_system_benchmarking() to get relevant results from the # benchmarking. urandom_test_succeeded = test_urandom_implemented() if not urandom_test_succeeded: return benchmarking_succeeded = perform_system_benchmarking() if not benchmarking_succeeded: return # Begin installation. if DISABLE_INSTALL: return # First, customize any scripts since they may be copied to new locations when # configuring seattle to run automatically at boot. # If running on a Windows system, customize the batch files. if OS == "Windows" or OS == "WindowsCE": customize_win_batch_files() _output("Done!") # If running on WindowsCE, setup the sitecustomize.py file. if OS == "WindowsCE": _output("Configuring python for WindowsCE...") setup_sitecustomize() _output("Done!") # Configure seattle to run at startup. if not DISABLE_STARTUP_SCRIPT: _output("Preparing Seattle to run automatically at startup...") # This try: block attempts to install seattle to run at startup. If it # fails, continue on with the rest of the install process (unless it # detects that seattle has already been installed) since the seattle # starter script may still be run even if seattle is not configured to run # at boot. try: # Any errors generated while configuring seattle to run at startup will be # printed in the child functions, unless an unexpected error is raised, # which will be caught in the general except Exception: block below. if OS == "Windows" or OS == "WindowsCE": setup_win_startup() _output("Seattle is setup to run at startup!") elif OS == "Linux" or OS == "Darwin": setup_success = setup_linux_or_mac_startup() if setup_success == None: # Do not print a final message to the user about setting up seattle to # run automatically at startup. pass elif setup_success: _output("Seattle is setup to run at startup!") else: # The reasons for which seattle was unable to be configured at startup # will have been logged by the service logger in the # setup_linux_or_mac_startup() function, and output for the possible # reasons why configuration to run at startup failed will have already # be given to the user from the setup_linux_or_mac_startup() function. _output("Seattle failed to be configured to run automatically at " \ + "startup.") else: raise UnsupportedOSError("This operating system is not supported.") except UnsupportedOSError,u: raise UnsupportedOSError(u) except AlreadyInstalledError,a: _output("seattle was already installed. " + str(a)) # Exit installation since seattle is already currently installed. return # If an unpredicted error is raised while setting up seattle to run at # startup, it is caught here. except Exception,e: _output("seattle could not be installed to run automatically at " \ + "startup for the following reason: " + str(e)) _output("Continuing with the installation process now. To manually " \ + "run seattle at any time, just run " \ + get_starter_file_name() + " from within the seattle " \ + "directory.") _output("Please contact the seattle project for further assistance.") servicelogger.log(time.strftime(" seattle was NOT installed on this " \ + "system for the following reason: " \ + str(e) + ". %m-%d-%Y %H:%M:%S")) # Generate the Node Manager keys even if configuring seattle to run # automatically at boot fails because Node Manager keys are needed for the # seattle_starter script which can be run at any time. _output("Generating the Node Manager RSA keys. This may take a few " \ + "minutes...") createnodekeys.initialize_keys(KEYBITSIZE, nodemanager_directory=SEATTLE_FILES_DIR) _output("Keys generated!") # Modify nodeman.cfg so the start_seattle script knows that seattle has been # installed. This is a new feature that will require seattle to have been # installed before it can be started. configuration = persist.restore_object("nodeman.cfg") configuration['seattle_installed'] = True persist.commit_object(configuration,"nodeman.cfg") # Everything has been installed, so start seattle and print concluding output # messages. _output("Starting seattle...") try: start_seattle() except Exception,e: _output("seattle could not be started for the following reason: " + str(e)) _output("Please contact the seattle project immediately for assistance.") servicelogger.log(time.strftime(" seattle installation failed. seattle " \ + "could not be started for the " \ + "following reason: " + str(e) + " " \ + "%m-%d-%Y %H:%M:%S")) else: _output("seattle has been installed!") _output("To learn more about useful, optional scripts related to running " \ + "seattle, see the README file.") servicelogger.log(time.strftime(" seattle completed installation on: " \ + "%m-%d-%Y %H:%M:%S"))
def main(): if OS not in SUPPORTED_OSES: raise UnsupportedOSError("This operating system is not supported.") # Begin pre-installation process. # Pre-install: parse the passed-in arguments. try: # Armon: Changed getopt to accept parameters for Repy and NM IP/Iface # restrictions, also a special disable flag opts, args = getopt.getopt(sys.argv[1:], "s", ["percent=", "nm-key-bitsize=","nm-ip=", "nm-iface=","repy-ip=","repy-iface=", "repy-nootherips","onlynetwork", "disable-startup-script","usage"]) except getopt.GetoptError, err: print str(err) usage() return # Derek Cheng: if the user is running a Nokia N800 tablet, we require them # to be on root first in order to have files created in the /etc/init.d and # /etc/rc2.d directories. if platform.machine().startswith('armv'): _output('Seattle is being installed on a Nokia N800/900 Internet Tablet.') # JAC: I can't import this on Windows, so will do it here... import pwd # if the current user name is not 'root' if pwd.getpwuid(os.getuid())[0] != 'root': _output('Please run the installer as root. This can be done by ' \ + 'installing/using the rootsh or openssh package.') return # Pre-install: process the passed-in arguments, and set up the configuration # dictionary. continue_install = prepare_installation(opts,args) if not continue_install: return # Pre-install: run all tests and benchmarking. # test_urandom_implemented() MUST be performed before # perform_system_benchmarking() to get relevant results from the # benchmarking. urandom_test_succeeded = test_urandom_implemented() if not urandom_test_succeeded: return benchmarking_succeeded = perform_system_benchmarking() if not benchmarking_succeeded: return # Begin installation. if DISABLE_INSTALL: return # First, customize any scripts since they may be copied to new locations when # configuring seattle to run automatically at boot. # If running on a Windows system, customize the batch files. if OS == "Windows" or OS == "WindowsCE": customize_win_batch_files() _output("Done!") # If running on WindowsCE, setup the sitecustomize.py file. if OS == "WindowsCE": _output("Configuring python for WindowsCE...") setup_sitecustomize() _output("Done!") # Configure seattle to run at startup. if not DISABLE_STARTUP_SCRIPT: _output("Preparing Seattle to run automatically at startup...") # This try: block attempts to install seattle to run at startup. If it # fails, continue on with the rest of the install process (unless it # detects that seattle has already been installed) since the seattle # starter script may still be run even if seattle is not configured to run # at boot. try: # Any errors generated while configuring seattle to run at startup will be # printed in the child functions, unless an unexpected error is raised, # which will be caught in the general except Exception: block below. if OS == "Windows" or OS == "WindowsCE": setup_win_startup() _output("Seattle is setup to run at startup!") elif OS == "Linux" or OS == "Darwin": setup_success = setup_linux_or_mac_startup() if setup_success == None: # Do not print a final message to the user about setting up seattle to # run automatically at startup. pass elif setup_success: _output("Seattle is setup to run at startup!") else: # The reasons for which seattle was unable to be configured at startup # will have been logged by the service logger in the # setup_linux_or_mac_startup() function, and output for the possible # reasons why configuration to run at startup failed will have already # be given to the user from the setup_linux_or_mac_startup() function. _output("Seattle failed to be configured to run automatically at " \ + "startup.") else: raise UnsupportedOSError("This operating system is not supported.") except UnsupportedOSError,u: raise UnsupportedOSError(u) except AlreadyInstalledError,a: _output("seattle was already installed. " + str(a)) # Exit installation since seattle is already currently installed. return # If an unpredicted error is raised while setting up seattle to run at # startup, it is caught here. except Exception,e: _output("seattle could not be installed to run automatically at " \ + "startup for the following reason: " + str(e)) _output("Continuing with the installation process now. To manually " \ + "run seattle at any time, just run " \ + get_starter_file_name() + " from within the seattle " \ + "directory.") _output("Please contact the seattle project for further assistance.") servicelogger.log(time.strftime(" seattle was NOT installed on this " \ + "system for the following reason: " \ + str(e) + ". %m-%d-%Y %H:%M:%S")) # Generate the Node Manager keys even if configuring seattle to run # automatically at boot fails because Node Manager keys are needed for the # seattle_starter script which can be run at any time. _output("Generating the Node Manager RSA keys. This may take a few " \ + "minutes...") createnodekeys.initialize_keys(KEYBITSIZE, nodemanager_directory=SEATTLE_FILES_DIR) _output("Keys generated!") # Modify nodeman.cfg so the start_seattle script knows that seattle has been # installed. This is a new feature that will require seattle to have been # installed before it can be started. configuration = persist.restore_object("nodeman.cfg") configuration['seattle_installed'] = True persist.commit_object(configuration,"nodeman.cfg") # Everything has been installed, so start seattle and print concluding output # messages. _output("Starting seattle...") try: start_seattle() except Exception,e: _output("seattle could not be started for the following reason: " + str(e)) _output("Please contact the seattle project immediately for assistance.") servicelogger.log(time.strftime(" seattle installation failed. seattle " \ + "could not be started for the " \ + "following reason: " + str(e) + " " \ + "%m-%d-%Y %H:%M:%S")) else: _output("seattle has been installed!") _output("To learn more about useful, optional scripts related to running " \ + "seattle, see the README file.") servicelogger.log(time.strftime(" seattle completed installation on: " \ + "%m-%d-%Y %H:%M:%S"))
477,695
def init(geni_username, vesselcount, vesseltype, program_filename, *args): """ <Purpose> Initializes the deployment of an arbitrary service. Populates a global configuration dictionary and returns a dict of data that could be required by the run() function. init() must be called before the run() function. Note on the return dict: The return value of init() is meant to contain data that is needed by calls to explib.start_vessel() within the run() function. At the time of creation of this library, the only such data that is required by deployable services is the user's GENI port. To add support for services requiring more arguments, simply add the necessary data to the dictionary returned by this function. <Arguments> geni_username SeattleGENI username. Used to locate and handle public and private key files. vesselcount The number of vessels on which to deploy. vesseltype The type of vessel to acquire, based on the SEATTLEGENI_VESSEL_TYPE_* constants within experimentlib.py program_filename The filename of the program to deploy and monitor on vessels. *args [Optional] Any additional arguments will be passed to the program deployed on vessels. <Exceptions> ValueError Raised if argument vesseltype doesn't match one of the experimentlib SEATTLEGENI_VESSEL_TYPE_* constants, if argument program file does not exist, or if argument number of vessels on which to deploy exceeds the user's number of vessel credits. <Side Effects> Initializes certain global variables. <Returns> A dictionary containing data that clients might need for running program on vessels. """ # Fill config dict with argument data # Validate vesseltype, based on constants in explib if vesseltype not in [explib.SEATTLEGENI_VESSEL_TYPE_WAN, explib.SEATTLEGENI_VESSEL_TYPE_LAN, explib.SEATTLEGENI_VESSEL_TYPE_NAT, explib.SEATTLEGENI_VESSEL_TYPE_RAND]: raise ValueError('Invalid vessel type specified. Argument vessel type must be one of the SEATTLEGENI_VESSEL_TYPE_* constants defined in experimentlib.py') config['vesseltype'] = vesseltype # Verify that program file exists if not os.path.isfile(program_filename): raise ValueError('Specified program file ' + program_filename + ' does not exist') config['program_filename'] = program_filename # Setup explib identity object and GENI details config['identity'] = explib.create_identity_from_key_files( geni_username + '.publickey', geni_username + '.privatekey') config['geni_port'] = explib.seattlegeni_user_port(config['identity']) # Validate number of vessels on which to deploy num_vslcredits = explib.seattlegeni_max_vessels_allowed(config['identity']) if vesselcount > num_vslcredits: raise ValueError('Invalid number of vessels specified. The number of deployed vessels must be less than or equal to the user\'s number of vessel credits.') config['vesselcount'] = vesselcount # Create and populate the return dict ret_dict = { 'geni_port': config['geni_port'] } return ret_dict
def init(geni_username, vesselcount, vesseltype, program_filename): """ <Purpose> Initializes the deployment of an arbitrary service. Populates a global configuration dictionary and returns a dict of data that could be required by the run() function. init() must be called before the run() function. Note on the return dict: The return value of init() is meant to contain data that is needed by calls to explib.start_vessel() within the run() function. At the time of creation of this library, the only such data that is required by deployable services is the user's GENI port. To add support for services requiring more arguments, simply add the necessary data to the dictionary returned by this function. <Arguments> geni_username SeattleGENI username. Used to locate and handle public and private key files. vesselcount The number of vessels on which to deploy. vesseltype The type of vessel to acquire, based on the SEATTLEGENI_VESSEL_TYPE_* constants within experimentlib.py program_filename The filename of the program to deploy and monitor on vessels. *args [Optional] Any additional arguments will be passed to the program deployed on vessels. <Exceptions> ValueError Raised if argument vesseltype doesn't match one of the experimentlib SEATTLEGENI_VESSEL_TYPE_* constants, if argument program file does not exist, or if argument number of vessels on which to deploy exceeds the user's number of vessel credits. <Side Effects> Initializes certain global variables. <Returns> A dictionary containing data that clients might need for running program on vessels. """ # Fill config dict with argument data # Validate vesseltype, based on constants in explib if vesseltype not in [explib.SEATTLEGENI_VESSEL_TYPE_WAN, explib.SEATTLEGENI_VESSEL_TYPE_LAN, explib.SEATTLEGENI_VESSEL_TYPE_NAT, explib.SEATTLEGENI_VESSEL_TYPE_RAND]: raise ValueError('Invalid vessel type specified. Argument vessel type must be one of the SEATTLEGENI_VESSEL_TYPE_* constants defined in experimentlib.py') config['vesseltype'] = vesseltype # Verify that program file exists if not os.path.isfile(program_filename): raise ValueError('Specified program file ' + program_filename + ' does not exist') config['program_filename'] = program_filename # Setup explib identity object and GENI details config['identity'] = explib.create_identity_from_key_files( geni_username + '.publickey', geni_username + '.privatekey') config['geni_port'] = explib.seattlegeni_user_port(config['identity']) # Validate number of vessels on which to deploy num_vslcredits = explib.seattlegeni_max_vessels_allowed(config['identity']) if vesselcount > num_vslcredits: raise ValueError('Invalid number of vessels specified. The number of deployed vessels must be less than or equal to the user\'s number of vessel credits.') config['vesselcount'] = vesselcount # Create and populate the return dict ret_dict = { 'geni_port': config['geni_port'] } return ret_dict
477,696
def init(geni_username, vesselcount, vesseltype, program_filename, *args): """ <Purpose> Initializes the deployment of an arbitrary service. Populates a global configuration dictionary and returns a dict of data that could be required by the run() function. init() must be called before the run() function. Note on the return dict: The return value of init() is meant to contain data that is needed by calls to explib.start_vessel() within the run() function. At the time of creation of this library, the only such data that is required by deployable services is the user's GENI port. To add support for services requiring more arguments, simply add the necessary data to the dictionary returned by this function. <Arguments> geni_username SeattleGENI username. Used to locate and handle public and private key files. vesselcount The number of vessels on which to deploy. vesseltype The type of vessel to acquire, based on the SEATTLEGENI_VESSEL_TYPE_* constants within experimentlib.py program_filename The filename of the program to deploy and monitor on vessels. *args [Optional] Any additional arguments will be passed to the program deployed on vessels. <Exceptions> ValueError Raised if argument vesseltype doesn't match one of the experimentlib SEATTLEGENI_VESSEL_TYPE_* constants, if argument program file does not exist, or if argument number of vessels on which to deploy exceeds the user's number of vessel credits. <Side Effects> Initializes certain global variables. <Returns> A dictionary containing data that clients might need for running program on vessels. """ # Fill config dict with argument data # Validate vesseltype, based on constants in explib if vesseltype not in [explib.SEATTLEGENI_VESSEL_TYPE_WAN, explib.SEATTLEGENI_VESSEL_TYPE_LAN, explib.SEATTLEGENI_VESSEL_TYPE_NAT, explib.SEATTLEGENI_VESSEL_TYPE_RAND]: raise ValueError('Invalid vessel type specified. Argument vessel type must be one of the SEATTLEGENI_VESSEL_TYPE_* constants defined in experimentlib.py') config['vesseltype'] = vesseltype # Verify that program file exists if not os.path.isfile(program_filename): raise ValueError('Specified program file ' + program_filename + ' does not exist') config['program_filename'] = program_filename # Setup explib identity object and GENI details config['identity'] = explib.create_identity_from_key_files( geni_username + '.publickey', geni_username + '.privatekey') config['geni_port'] = explib.seattlegeni_user_port(config['identity']) # Validate number of vessels on which to deploy num_vslcredits = explib.seattlegeni_max_vessels_allowed(config['identity']) if vesselcount > num_vslcredits: raise ValueError('Invalid number of vessels specified. The number of deployed vessels must be less than or equal to the user\'s number of vessel credits.') config['vesselcount'] = vesselcount # Create and populate the return dict ret_dict = { 'geni_port': config['geni_port'] } return ret_dict
def init(geni_username, vesselcount, vesseltype, program_filename, *args): """ <Purpose> Initializes the deployment of an arbitrary service. Populates a global configuration dictionary and returns a dict of data that could be required by the run() function. init() must be called before the run() function. Note on the return dict: The return value of init() is meant to contain data that is needed by calls to explib.start_vessel() within the run() function. At the time of creation of this library, the only such data that is required by deployable services is the user's GENI port. To add support for services requiring more arguments, simply add the necessary data to the dictionary returned by this function. <Arguments> geni_username SeattleGENI username. Used to locate and handle public and private key files. vesselcount The number of vessels on which to deploy. vesseltype The type of vessel to acquire, based on the SEATTLEGENI_VESSEL_TYPE_* constants within experimentlib.py program_filename The filename of the program to deploy and monitor on vessels. <Exceptions> ValueError Raised if argument vesseltype doesn't match one of the experimentlib SEATTLEGENI_VESSEL_TYPE_* constants, if argument program file does not exist, or if argument number of vessels on which to deploy exceeds the user's number of vessel credits. <Side Effects> Initializes certain global variables. <Returns> A dictionary containing data that clients might need for running program on vessels. """ # Fill config dict with argument data # Validate vesseltype, based on constants in explib if vesseltype not in [explib.SEATTLEGENI_VESSEL_TYPE_WAN, explib.SEATTLEGENI_VESSEL_TYPE_LAN, explib.SEATTLEGENI_VESSEL_TYPE_NAT, explib.SEATTLEGENI_VESSEL_TYPE_RAND]: raise ValueError('Invalid vessel type specified. Argument vessel type must be one of the SEATTLEGENI_VESSEL_TYPE_* constants defined in experimentlib.py') config['vesseltype'] = vesseltype # Verify that program file exists if not os.path.isfile(program_filename): raise ValueError('Specified program file ' + program_filename + ' does not exist') config['program_filename'] = program_filename # Setup explib identity object and GENI details config['identity'] = explib.create_identity_from_key_files( geni_username + '.publickey', geni_username + '.privatekey') config['geni_port'] = explib.seattlegeni_user_port(config['identity']) # Validate number of vessels on which to deploy num_vslcredits = explib.seattlegeni_max_vessels_allowed(config['identity']) if vesselcount > num_vslcredits: raise ValueError('Invalid number of vessels specified. The number of deployed vessels must be less than or equal to the user\'s number of vessel credits.') config['vesselcount'] = vesselcount # Create and populate the return dict ret_dict = { 'geni_port': config['geni_port'] } return ret_dict
477,697
def assertisallowed(call,*args): # let's pre-reject certain open / file calls #print call_rule_table[call] matches = find_action(call_rule_table[call], args) action, matched_rule, reasoning = matches[0] if action == 'allow': return True elif action == 'deny': matches.reverse() estr = "Call '"+str(call)+"' with args "+str(args)+" not allowed\n" estr += "Matching dump:\n" for action, matched_rule, reasoning in matches: if matched_rule != '': estr += "rule: "+str(matched_rule) + ", " estr += str(reasoning) + "\n" raise Exception, estr elif action == 'prompt': # would do an upcall here... raise Exception, "Call '"+ str(call)+"' not allowed" else: # This will cause the program to exit and log things if logging is # enabled. -Brent tracebackrepy.handle_internalerror("find_action returned '" + str(action) + "' for call '" + str(call) + "'", 31)
def assertisallowed(call,*args): # let's pre-reject certain open / file calls #print call_rule_table[call] matches = find_action(call_rule_table[call], args) action, matched_rule, reasoning = matches[0] if action == 'allow': return True elif action == 'deny': matches.reverse() estr = "Call '"+str(call)+"' with args "+str(args)+" not allowed\n" estr += "Matching dump:\n" for action, matched_rule, reasoning in matches: if matched_rule != '': estr += "rule: "+str(matched_rule) + ", " estr += str(reasoning) + "\n" raise Exception, estr elif action == 'prompt': # would do an upcall here... raise Exception, "Call '"+ str(call)+"' not allowed" else: # This will cause the program to exit and log things if logging is # enabled. -Brent tracebackrepy.handle_internalerror("find_action returned '" + str(action) + "' for call '" + str(call) + "'", 31)
477,698
def seattlegeni_renew_vessels(identity, vesselhandle_list): """ <Purpose> Renew vessels previously acquired from SeattleGENI. <Arguments> identity The identity to use for communicating with SeattleGENI. vesselhandle_list The vessels to be renewed. <Exceptions> The common SeattleGENI exceptions described in the module comments, as well as: SeattleGENINotEnoughCredits If the account is currently over its vessel credit limit, then vessels cannot be renewed until the account is no longer over its credit limit. <Side Effects> The expiration time of the vessels is is reset to the maximum. <Returns> None """ _validate_vesselhandle_list(vesselhandle_list) client = _get_seattlegeni_client(identity) _call_seattlegeni_func(client.renew_vessels, vesselhandle_list)
def seattlegeni_renew_vessels(identity, vesselhandle_list): """ <Purpose> Renew vessels previously acquired from SeattleGENI. <Arguments> identity The identity to use for communicating with SeattleGENI. vesselhandle_list The vessels to be renewed. <Exceptions> The common SeattleGENI exceptions described in the module comments, as well as: SeattleGENINotEnoughCredits If the account is currently over its vessel credit limit, then vessels cannot be renewed until the account is no longer over its credit limit. <Side Effects> The expiration time of the vessels is is reset to the maximum. <Returns> None """ _validate_vesselhandle_list(vesselhandle_list) client = _get_seattlegeni_client(identity) _call_seattlegeni_func(client.renew_resources, vesselhandle_list)
477,699