rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
bdb_put2 = cfunc('tcbdbput2', libtc, c_bool, ('bdb', c_void_p, 1), ('kstr', c_char_p, 1), ('vstr', c_char_p, 1)) | bdb_put2 = cfunc_fast('tcbdbput2', libtc, c_bool, ('bdb', c_void_p, 1), ('kstr', c_char_p, 1), ('vstr', c_char_p, 1)) | def __del__(self): if self and libtc: libtc.tcmapdel(self) |
bdb_putkeep2 = cfunc('tcbdbputkeep2', libtc, c_bool, ('bdb', c_void_p, 1), ('kstr', c_char_p, 1), ('vstr', c_char_p, 1)) | bdb_putkeep2 = cfunc_fast('tcbdbputkeep2', libtc, c_bool, ('bdb', c_void_p, 1), ('kstr', c_char_p, 1), ('vstr', c_char_p, 1)) | def __del__(self): if self and libtc: libtc.tcmapdel(self) |
bdb_putcat2 = cfunc('tcbdbputcat2', libtc, c_bool, ('bdb', c_void_p, 1), ('kstr', c_char_p, 1), ('vstr', c_char_p, 1)) | bdb_putcat2 = cfunc_fast('tcbdbputcat2', libtc, c_bool, ('bdb', c_void_p, 1), ('kstr', c_char_p, 1), ('vstr', c_char_p, 1)) | def __del__(self): if self and libtc: libtc.tcmapdel(self) |
bdb_putdup2 = cfunc('tcbdbputdup2', libtc, c_bool, ('bdb', c_void_p, 1), ('kstr', c_char_p, 1), ('vstr', c_char_p, 1)) | bdb_putdup2 = cfunc_fast('tcbdbputdup2', libtc, c_bool, ('bdb', c_void_p, 1), ('kstr', c_char_p, 1), ('vstr', c_char_p, 1)) | def __del__(self): if self and libtc: libtc.tcmapdel(self) |
bdb_out2 = cfunc('tcbdbout2', libtc, c_bool, ('bdb', c_void_p, 1), ('kstr', c_char_p, 1)) | bdb_out2 = cfunc_fast('tcbdbout2', libtc, c_bool, ('bdb', c_void_p, 1), ('kstr', c_char_p, 1)) | def __del__(self): if self and libtc: libtc.tcmapdel(self) |
bdb_get2 = cfunc('tcbdbget2', libtc, tc_char_p, ('bdb', c_void_p, 1), ('kstr', c_char_p, 1)) | bdb_get2 = cfunc_fast('tcbdbget2', libtc, tc_char_p, ('bdb', c_void_p, 1), ('kstr', c_char_p, 1)) | def __del__(self): if self and libtc: libtc.tcmapdel(self) |
bdb_vnum2 = cfunc('tcbdbvnum2', libtc, int, ('bdb', c_void_p, 1), ('kstr', c_char_p, 1)) | bdb_vnum2 = cfunc_fast('tcbdbvnum2', libtc, int, ('bdb', c_void_p, 1), ('kstr', c_char_p, 1)) | def __del__(self): if self and libtc: libtc.tcmapdel(self) |
bdb_vsiz2 = cfunc('tcbdbvsiz2', libtc, c_int, ('bdb', c_void_p, 1), ('kstr', c_char_p, 1)) | bdb_vsiz2 = cfunc_fast('tcbdbvsiz2', libtc, c_int, ('bdb', c_void_p, 1), ('kstr', c_char_p, 1)) | def __del__(self): if self and libtc: libtc.tcmapdel(self) |
bdb_range2 = cfunc('tcbdbrange2', libtc, TCLIST_P, ('bdb', c_void_p, 1), ('bkstr', c_char_p, 1), ('binc', c_bool, 1), ('ekstr', c_char_p, 1), ('einc', c_bool, 1), ('max', c_int, 1, -1)) | bdb_range2 = cfunc_fast('tcbdbrange2', libtc, TCLIST_P, ('bdb', c_void_p, 1), ('bkstr', c_char_p, 1), ('binc', c_bool, 1), ('ekstr', c_char_p, 1), ('einc', c_bool, 1), ('max', c_int, 1, -1)) | def __del__(self): if self and libtc: libtc.tcmapdel(self) |
bdb_fwmkeys2 = cfunc('tcbdbfwmkeys2', libtc, TCLIST_P, ('bdb', c_void_p, 1), ('pstr', c_char_p, 1), ('max', c_int, 1, -1)) | bdb_fwmkeys2 = cfunc_fast('tcbdbfwmkeys2', libtc, TCLIST_P, ('bdb', c_void_p, 1), ('pstr', c_char_p, 1), ('max', c_int, 1, -1)) | def __del__(self): if self and libtc: libtc.tcmapdel(self) |
bdb_curjump2 = cfunc('tcbdbcurjump2', libtc, c_bool, ('cur', c_void_p, 1), ('kstr', c_char_p, 1)) | bdb_curjump2 = cfunc_fast('tcbdbcurjump2', libtc, c_bool, ('cur', c_void_p, 1), ('kstr', c_char_p, 1)) | def __del__(self): if self and libtc: libtc.tcmapdel(self) |
bdb_curput2 = cfunc('tcbdbcurput2', libtc, c_bool, ('cur', c_void_p, 1), ('vstr', c_char_p, 1), ('cpmode', c_int, 1)) | bdb_curput2 = cfunc_fast('tcbdbcurput2', libtc, c_bool, ('cur', c_void_p, 1), ('vstr', c_char_p, 1), ('cpmode', c_int, 1)) | def __del__(self): if self and libtc: libtc.tcmapdel(self) |
bdb_curkey2 = cfunc('tcbdbcurkey2', libtc, tc_char_p, ('cur', c_void_p, 1)) | bdb_curkey2 = cfunc_fast('tcbdbcurkey2', libtc, tc_char_p, ('cur', c_void_p, 1)) | def __del__(self): if self and libtc: libtc.tcmapdel(self) |
bdb_curval2 = cfunc('tcbdbcurval2', libtc, tc_char_p, ('cur', c_void_p, 1)) | bdb_curval2 = cfunc_fast('tcbdbcurval2', libtc, tc_char_p, ('cur', c_void_p, 1)) | def __del__(self): if self and libtc: libtc.tcmapdel(self) |
bdb_putdupback2 = cfunc('tcbdbputdupback2', libtc, c_bool, ('bdb', c_void_p, 1), ('kstr', c_char_p, 1), ('vstr', c_char_p, 1)) | bdb_putdupback2 = cfunc_fast('tcbdbputdupback2', libtc, c_bool, ('bdb', c_void_p, 1), ('kstr', c_char_p, 1), ('vstr', c_char_p, 1)) | def __del__(self): if self and libtc: libtc.tcmapdel(self) |
bdb_curjumpback2 = cfunc('tcbdbcurjumpback2', libtc, c_bool, ('cur', c_void_p, 1), ('kstr', c_char_p, 1)) | bdb_curjumpback2 = cfunc_fast('tcbdbcurjumpback2', libtc, c_bool, ('cur', c_void_p, 1), ('kstr', c_char_p, 1)) | def __del__(self): if self and libtc: libtc.tcmapdel(self) |
class tc_uint64_p(c_uint64_p): | class tc_uint64_p(c_void_p): | def __del__(self): if self and libtc: libtc.tcfree(self) |
fdb_del = cfunc('tcfdb', libtc, None, | fdb_del = cfunc('tcfdbdel', libtc, None, | def __del__(self): if self and libtc: libtc.tclistdel(self) |
fdb_ecode = cfunc('tcfdb', libtc, c_int, | fdb_ecode = cfunc('tcfdbecode', libtc, c_int, | def __del__(self): if self and libtc: libtc.tclistdel(self) |
fdb_open = cfunc('tcfdbopen', libtc, None, | fdb_open = cfunc('tcfdbopen', libtc, c_bool, | def __del__(self): if self and libtc: libtc.tclistdel(self) |
fdb_close = cfunc('tcfdb', libtc, c_bool, | fdb_close = cfunc('tcfdbclose', libtc, c_bool, | def __del__(self): if self and libtc: libtc.tclistdel(self) |
fdb_range.errcheck = lambda result, func, arguments : (result, arguments[3]) | fdb_range.errcheck = lambda result, func, arguments : (result, arguments[4]) | def __del__(self): if self and libtc: libtc.tclistdel(self) |
('fdb', c_void_p, 1)) | ('fdb', c_void_p, 1), ('id', c_int64, 1), ('num', c_double, 1)) | def __del__(self): if self and libtc: libtc.tclistdel(self) |
fdb_putporc = cfunc('tcfdbputporc', libtc, c_bool, | fdb_putproc = cfunc('tcfdbputproc', libtc, c_bool, | def __del__(self): if self and libtc: libtc.tclistdel(self) |
fdb_putporc.__doc__ =\ | fdb_putproc.__doc__ =\ | def __del__(self): if self and libtc: libtc.tclistdel(self) |
def foreach(self, proc, op, raw_key=False, value_type=None): | def foreach(self, proc, op, key_type=False, value_type=None): | def foreach(self, proc, op, raw_key=False, value_type=None): """Process each record atomically of a hash database object.""" def proc_wraper(c_key, c_key_len, c_value, c_value_len, op): key = util.deserialize(ctypes.cast(c_key, ctypes.c_void_p), c_key_len, raw_key) value = util.deserialize(ctypes.cast(c_value, ctypes.c... |
c_key_len, raw_key) | c_key_len, key_type) | def proc_wraper(c_key, c_key_len, c_value, c_value_len, op): key = util.deserialize(ctypes.cast(c_key, ctypes.c_void_p), c_key_len, raw_key) value = util.deserialize(ctypes.cast(c_value, ctypes.c_void_p), c_value_len, value_type) return proc(key, value, ctypes.cast(op, ctypes.c_char_p).value) |
pks = [1+1j, 'some text [áéíóú]', 10, 10.0] | pks = [1+1j, 'some text [áéíóú]', 10, 10.0, 't1', 't2', 't3', 't4'] | def test_qry(self): pks = [1+1j, 'some text [áéíóú]', 10, 10.0] for pk in pks: cols = self.row(str(pk)) cols['order'] = random.choice(range(50)) self.tdb.put(pk, cols, raw_cols=True) |
self.assertEqual(len(r), 4) | self.assertEqual(len(r), 8) | def test_qry(self): pks = [1+1j, 'some text [áéíóú]', 10, 10.0] for pk in pks: cols = self.row(str(pk)) cols['order'] = random.choice(range(50)) self.tdb.put(pk, cols, raw_cols=True) |
qry.setorder('order', tdb.QONUMASC) | qry.setorder('order', tdb.QOSTRASC) | def test_qry(self): pks = [1+1j, 'some text [áéíóú]', 10, 10.0] for pk in pks: cols = self.row(str(pk)) cols['order'] = random.choice(range(50)) self.tdb.put(pk, cols, raw_cols=True) |
result = tc.hdb_optimize(self.db, *kwargs) | result = tc.hdb_optimize(self.db, **kwargs) | def optimize(self, bnum=None, apow=None, fpow=None, opts=None): """Optimize the file of a hash database object.""" kwargs = dict([x for x in (('bnum', bnum), ('apow', apow), ('fpow', fpow), ('opts', opts)) if x[1]]) result = tc.hdb_optimize(self.db, *kwargs) if not result: raise tc.TCException(tc.hdb_errmsg(tc.hdb_ecod... |
fdb_.__doc__ =\ | fdb_out3.__doc__ =\ | def __del__(self): if self and libtc: libtc.tclistdel(self) |
fdb_iternext3 = cfunc('tcfdbiternext3', libtc, c_char_p, | fdb_iternext3 = cfunc('tcfdbiternext3', libtc, tc_char_p, | def __del__(self): if self and libtc: libtc.tclistdel(self) |
fdb_range5 = cfunc('tcfdbrange5', libtc, TCLISP_P, | fdb_range5 = cfunc('tcfdbrange5', libtc, TCLIST_P, | def __del__(self): if self and libtc: libtc.tclistdel(self) |
fdb_.__doc__ =\ | fdb_max.__doc__ =\ | def __del__(self): if self and libtc: libtc.tclistdel(self) |
tcmapget = cfunc('tcmapget', libtc, tc_void_p, | tcmapget = cfunc('tcmapget', libtc, c_void_p, | def __del__(self): if self and libtc: libtc.tcmapdel(self) |
tcmapget2 = cfunc('tcmapget2', libtc, tc_char_p, | tcmapget2 = cfunc('tcmapget2', libtc, c_char_p, | def __del__(self): if self and libtc: libtc.tcmapdel(self) |
tcmapiternext = cfunc('tcmapiternext', libtc, tc_void_p, | tcmapiternext = cfunc('tcmapiternext', libtc, c_void_p, | def __del__(self): if self and libtc: libtc.tcmapdel(self) |
tcmapiternext2 = cfunc('tcmapiternext2', libtc, tc_char_p, | tcmapiternext2 = cfunc('tcmapiternext2', libtc, c_char_p, | def __del__(self): if self and libtc: libtc.tcmapdel(self) |
tcmapget3 = cfunc('tcmapget3', libtc, tc_void_p, | tcmapget3 = cfunc('tcmapget3', libtc, c_void_p, | def __del__(self): if self and libtc: libtc.tcmapdel(self) |
tcmapget4 = cfunc('tcmapget4', libtc, tc_char_p, | tcmapget4 = cfunc('tcmapget4', libtc, c_char_p, | def __del__(self): if self and libtc: libtc.tcmapdel(self) |
tcmapiterval = cfunc('tcmapiterval', libtc, tc_void_p, | tcmapiterval = cfunc('tcmapiterval', libtc, c_void_p, | def __del__(self): if self and libtc: libtc.tcmapdel(self) |
tcmapiterval2 = cfunc('tcmapiterval2', libtc, tc_char_p, | tcmapiterval2 = cfunc('tcmapiterval2', libtc, c_char_p, | def __del__(self): if self and libtc: libtc.tcmapdel(self) |
tcmaploadone = cfunc('tcmaploadone', libtc, tc_void_p, | tcmaploadone = cfunc('tcmaploadone', libtc, c_void_p, | def __del__(self): if self and libtc: libtc.tcmapdel(self) |
self.hdb.putasync('obj', obj1) obj2 = self.hdb.get('obj') self.assertEqual(obj1, obj2) | def test_putasync(self): objs = [1+1j, 'some text [áéíóú]', u'unicode text [áéíóú]', 10, 10.0] for obj1 in objs: self.hdb.putasync('obj', obj1) obj2 = self.hdb.get('obj') self.assertEqual(obj1, obj2) | |
self.InitialState(self.on) | self.Initialize(self.on) | def __init__(self, entry): self.entry = entry self.InitialState(self.on) |
shutil.copyfile(textureFile, os.path.join(classes.Configuration.osxFolder, parts[2], result.group(1))) | lastSlash = result.group(1).rfind("/") if (lastSlash > -1): destinationTexturePath = os.path.join(classes.Configuration.osxFolder, parts[2], result.group(1)[0:lastSlash]) else: destinationTexturePath = os.path.join(classes.Configuration.osxFolder, parts[2]) if not os.path.isdir(destinationTexturePath): os.makedirs(des... | def handleFacade(dirpath, filename, libraryFileHandle, libraryPlaceholderFileHandle, currentCategory, authors, textures): """ Create an instance of the SceneryObject class for a .fac """ objectSourcePath = os.path.join(dirpath, filename) parts = dirpath.split(os.sep, 2) displayMessage(".") # Create an instance of th... |
shutil.copyfile(textureFile, os.path.join(classes.Configuration.osxFolder, parts[2], result.group(1))) | lastSlash = result.group(1).rfind("/") if (lastSlash > -1): destinationTexturePath = os.path.join(classes.Configuration.osxFolder, parts[2], result.group(1)[0:lastSlash]) else: destinationTexturePath = os.path.join(classes.Configuration.osxFolder, parts[2]) if not os.path.isdir(destinationTexturePath): os.makedirs(des... | def handleForest(dirpath, filename, libraryFileHandle, libraryPlaceholderFileHandle, currentCategory, authors, textures): """ Create an instance of the SceneryObject class for a .for """ objectSourcePath = os.path.join(dirpath, filename) parts = dirpath.split(os.sep, 2) displayMessage(".") # Create an instance of th... |
shutil.copyfile(textureFile, os.path.join(classes.Configuration.osxFolder, parts[2], result.group(1))) | lastSlash = result.group(1).rfind("/") if (lastSlash > -1): destinationTexturePath = os.path.join(classes.Configuration.osxFolder, parts[2], result.group(1)[0:lastSlash]) else: destinationTexturePath = os.path.join(classes.Configuration.osxFolder, parts[2]) if not os.path.isdir(destinationTexturePath): os.makedirs(des... | def handleLine(dirpath, filename, libraryFileHandle, libraryPlaceholderFileHandle, currentCategory, authors, textures): """ Create an instance of the SceneryObject class for a .lin """ objectSourcePath = os.path.join(dirpath, filename) parts = dirpath.split(os.sep, 2) displayMessage(".") # Create an instance of the ... |
htmlFileContent += "<img src='" + sceneryObject.logoFileName + "' alt='Object branding logo' />\n" | htmlFileContent += "<img src='/doc/" + sceneryObject.logoFileName + "' alt='Object branding logo' />\n" | def writeHTMLDocFile(sceneryObject): """ Write a documentation file for the given SceneryObject to disk """ htmlFileContent = "" # Breadcrumbs htmlFileContent += "<div id='breadcrumbs'>\n" htmlFileContent += "<ul class='inline'>" sceneryCategoryAncestors = sceneryObject.sceneryCategory.getAncestors(1) for sceneryCate... |
result += "<ul id='menu0' class='menu noaccordion'>\n" | result += "<ul id='menu" + str(menuIndex) + "' class='menu noaccordion'>\n" menuIndex = menuIndex + 1 | def getHTMLTOC(rootCategory): """ Get the table of contents for the home page """ menuIndex = 0 result = "<div id='toc'>\n" result += "<h2>Contents</h2>\n" result += "<ul id='menu0' class='menu noaccordion'>\n" for mainSceneryCategory in rootCategory.childSceneryCategories: # Top-level types of item result += "<li>\... |
result += "<script src='http://widgets.twimg.com/j/2/widget.js'></script>\n" result += "<script>\n" | result += "<script src='http://widgets.twimg.com/j/2/widget.js' type='text/javascript'></script>\n" result += "<script type='text/javascript'>\n" | def getHTMLTOC(rootCategory): """ Get the table of contents for the home page """ menuIndex = 0 result = "<div id='toc'>\n" result += "<h2>Contents</h2>\n" result += "<ul id='menu0' class='menu noaccordion'>\n" for mainSceneryCategory in rootCategory.childSceneryCategories: # Top-level types of item result += "<li>\... |
if '/etc/rc.d/init.d' in contents: | if ('/etc/rc.d/init.d' != m.initdir and '/etc/rc.d/init.d' in contents): | def doFile(self, path): if hasattr(self.recipe, '_getCapsulePathsForFile'): if self.recipe._getCapsulePathsForFile(path): return |
str.__init__(self, dname) | str.__init__(self) | def __init__(self, dname): str.__init__(self, dname) pairs = [x.replace('\,', ',') for x in re.split(r'(?<!\\),\s*', dname)] for pair in pairs: try: name, value = pair.split(':', 1) except ValueError: raise ValueError("Invalid certificate access list: %s" % dname) if name not in self.ids: raise ValueError("Invalid auth... |
>>> parseAddress('0x0123456789abcdef') (81985529216486895L, 6) >>> parseAddress('123.123.123.123') (2071690107L, 4) >>> parseAddress('123.123') (2071658496L, 4) >>> parseAddress('1080:0000:0000:0000:0008:0800:200C:417A') (21932261930451111902915077091070067066L, 6) >>> parseAddress('1080:0:0:0:8:800:200C:417A') (219322... | >>> def testParseAddress(address): ... ip, version = parseAddress(address) ... print("%s (IPv%s)" % (ip, version)) ... >>> testParseAddress('0x0123456789abcdef') 81985529216486895 (IPv6) >>> testParseAddress('123.123.123.123') 2071690107 (IPv4) >>> testParseAddress('123.123') 2071658496 (IPv4) >>> testParseAddr... | def parseAddress(ipstr): """ Parse a string and return the corresponding IP address (as integer) and a guess of the IP version. Following address formats are recognized: >>> parseAddress('0x0123456789abcdef') # IPv4 if <= 0xffffffff else IPv6 (81985529216486895L, 6) >>> parseAddress('123.123.123.123') ... |
s._set_pos_astro(DOY,heureTU,lat) | s._set_pos_astro(DOY,heureTU,3.14/180*lat) | def __call__(self, Rsun,DOY,heureTU,lat): s=Sun.Sun() s.Rsun=Rsun s._set_pos_astro(DOY,heureTU,lat) |
Logger._time_eanbled = not not enable | Logger._time_enabled = not not enable | def _enable_time(self, enable): CPL_recipe.set_msg_time(enable); Logger._time_eanbled = not not enable |
Using a HDU list is useful when it needs to be patched before fed into the recipe. Note that HDU lists are stored in temporary files before the recipe is called which may produce some overhead. Also, the CPL then assigns the temporary file names to the | Using :class:`pyfits.HDUList` is useful when it needs to be patched before fed into the recipe. | def calib(self): '''This attribute contains the calibration frames for the recipe. It is iterable and then returns all calibration frames: >>> for f in muse_scibasic.calib: ... print f.tag, f.min, f.max, f.files TRACE_TABLE 1 1 None WAVECAL_TABLE 1 1 None MASTER_BIAS 1 1 master_bias_0.fits MASTER_DARK None 1 None... |
str(self.version), str(version), name, filename) | (str(self.version), str(version), name, filename)) | def __init__(self, name, filename = None, version = None): '''Try to load a recipe with the specified name in the directory specified by the module variable 'recipe_dir' or its subdirectories. ''' self._recipe = None self.name = name if not filename: filename = Recipe.get_recipefilename(name, version) self.filename = f... |
self.start() | Threaded.queue.add(self) | def __init__(self, func, *args, **nargs): threading.Thread.__init__(self) self._func = func self._args = args self._nargs = nargs self._res = None self._exception = None self.start() |
if tag.lower() not in self.__dict__: self.__dict__[tag] = hdu | if tag.lower() not in self.__dict__: self.__dict__[tag] = [ hdu ] if force_list else hdu | def __init__(self, recipedefs, res, delete = True, force_list = False): self.dir = os.getcwd() if res[0]: msg.info("Result frames:" ) msg.indent_more() for tag, frame in res[0]: msg.info("%s = %s" % (tag, frame)) msg.indent_less() if res[1][0]: raise CplError(res[1][0], res[1][1], res[1][2], res[1][3], res[1][4]) self... |
elif isinstance(self.__dict__[tag], pyfits.HDUList) \ and not force_list: | elif isinstance(self.__dict__[tag], pyfits.HDUList): | def __init__(self, recipedefs, res, delete = True, force_list = False): self.dir = os.getcwd() if res[0]: msg.info("Result frames:" ) msg.indent_more() for tag, frame in res[0]: msg.info("%s = %s" % (tag, frame)) msg.indent_less() if res[1][0]: raise CplError(res[1][0], res[1][1], res[1][2], res[1][3], res[1][4]) self... |
results.append(self.recipe(self.raw_frame, param_intopt = i)) | results.append(self.recipe(self.raw_frame, param_intopt = i, threaded = True)) | def test_parallel(self): '''Parallel execution''' results = list() for i in range(20): # mark each frame so that we can see their order self.raw_frame[0].header.update('HIERARCH ESO RAW1 NR', i) results.append(self.recipe(self.raw_frame, param_intopt = i)) for i, res in enumerate(results): # check if we got the correct... |
:param source: SOF file name. | :param source: SOF file object or string with sof file content. | def load_sof(source): '''Read an esorex sof file. :param source: SOF file name. :type source: :class:`str` or :class:`file` These files contain the raw and calibration files for a recipe. The content of the file is returned as a map with the tag as key and the list of file names as value. The result of this functio... |
myrecipe.calib = cpl.esorex.read_sof('muse_bias.sof') | myrecipe.calib = cpl.esorex.read_sof(file('muse_bias.sof')) | def load_sof(source): '''Read an esorex sof file. :param source: SOF file name. :type source: :class:`str` or :class:`file` These files contain the raw and calibration files for a recipe. The content of the file is returned as a map with the tag as key and the list of file names as value. The result of this functio... |
:param source: Configuration file name. If not set, the esorex config file | :param source: Configuration file object, or string with file content. If not set, the esorex config file | def load_rc(source = None): '''Read an esorex configuration file. :param source: Configuration file name. If not set, the esorex config file :file:`~/.esorex/esorex.rc` is used. :type source: :class:`str` or :class:`file` These files contain configuration parameters for esorex or recipes. The content of the file is r... |
self.destroy() | self.destroy(False) | def check_timeout(self): now = datetime.datetime.now() if now > self.date_usage + self.REMOVE_TIMEOUT: self.logger().log("timeout: removing topology") self.remove() elif now > self.date_usage + self.DESTROY_TIMEOUT: self.logger().log("timeout: destroying topology") self.destroy() elif now > self.date_usage + self.STOP_... |
self.stop() | self.stop(False) | def check_timeout(self): now = datetime.datetime.now() if now > self.date_usage + self.REMOVE_TIMEOUT: self.logger().log("timeout: removing topology") self.remove() elif now > self.date_usage + self.DESTROY_TIMEOUT: self.logger().log("timeout: destroying topology") self.destroy() elif now > self.date_usage + self.STOP_... |
def stop(self): | def stop(self, renew=True): | def stop(self): """ Stops the topology. This will fail if the topology has not been prepared yet. """ self.renew() task = self.start_task(self.stop_run) return task.id |
self.renew() | if renew: self.renew() | def stop(self): """ Stops the topology. This will fail if the topology has not been prepared yet. """ self.renew() task = self.start_task(self.stop_run) return task.id |
def destroy(self): | def destroy(self, renew=True): | def destroy(self): """ Destroys the topology. This will fail if the topology has not been uploaded yet or is already started. """ self.renew() task = self.start_task(self.destroy_run) return task.id |
self.renew() | if renew: self.renew() | def destroy(self): """ Destroys the topology. This will fail if the topology has not been uploaded yet or is already started. """ self.renew() task = self.start_task(self.destroy_run) return task.id |
request.session.api = xmlrpclib.ServerProxy('http://%s:%s@localhost:8000' % (username, password) ) | try: api = xmlrpclib.ServerProxy('http://%s:%s@localhost:8000' % (username, password) ) request.session.api = api api.account() except: raise xmlrpclib.Fault("-1", "Unauthorized") | def getapi(request): auth=getauth(request) if not auth: return None (username, password) = auth request.session.api = xmlrpclib.ServerProxy('http://%s:%s@localhost:8000' % (username, password) ) return True |
if self.interface.connection: | try: con = self.interface.connection | def decode_xml(self, dom): try: device_name = dom.getAttribute("device") device = self.connector.topology.devices_get(device_name) iface_name = dom.getAttribute("interface") self.interface = device.interfaces_get(iface_name) if self.interface.connection: raise fault.new(fault.DUPLICATE_INTERFACE_CONNECTION, "Interface ... |
def add(request): | def add(api, request): | def add(request): name=request.REQUEST["name"] type=request.REQUEST["type"] api.template_add(name, type) return index(request) |
def remove(request, name): | def remove(api, request, name): | def remove(request, name): api.template_remove(name) return index(request) |
return Topology.objects.get(id=id) | try: return Topology.objects.get(id=id) except Topology.DoesNotExit: raise fault.new(fault.NO_SUCH_TOPOLOGY, "No such topology: %s" % id) | def get(id): return Topology.objects.get(id=id) |
self.host.execute("qm set %s --ide0 local:%s/disk.qcow2" % (self.kvm_id, self.kvm_id, self.template), task) | self.host.execute("qm set %s --ide0 local:%s/disk.qcow2" % (self.kvm_id, self.kvm_id), task) | def prepare_run(self, task): generic.Device.prepare_run(self, task) self.host.execute("qm create %s" % self.kvm_id, task) self.host.execute("mkdir -p /var/lib/vz/images/%s" % self.kvm_id, task) self.host.execute("cp /var/lib/vz/template/qemu/%s /var/lib/vz/images/%s/disk.qcow2" % (self.template, self.kvm_id), task) sel... |
fd.write("( while true; do vncterm -rfport %s -passwd %s -c vzctl enter %s ) & echo $! > vnc-%s.pid" % ( self.vnc_port, self.vnc_password(), self.openvz_id, self.id ) ) | fd.write("( while true; do vncterm -rfbport %s -passwd %s -c vzctl enter %s ; done ) & echo $! > vnc-%s.pid" % ( self.vnc_port, self.vnc_password(), self.openvz_id, self.id ) ) | def write_control_script(self, host, script, fd): """ Write the control script for this object and its child objects """ if script == "prepare": fd.write("vzctl create %s --ostemplate %s\n" % ( self.openvz_id, self.template ) ) fd.write("vzctl set %s --devices c:10:200:rw --capability net_admin:on --save\n" % self.ope... |
if self.type == "router": table_in = 1000 + 2 * con.id table_out = 1000 + 2 * con.id + 1 host.execute ( "iptables -t mangle -D PREROUTING -i %s -j MARK --set-mark %s" % ( tincname, table_in ), task ) host.execute ( "iptables -t mangle -D PREROUTING -i %s -j MARK --set-mark %s" % ( con.bridge_name(), table_out ), task )... | if host: if self.type == "router": table_in = 1000 + 2 * con.id table_out = 1000 + 2 * con.id + 1 host.execute ( "iptables -t mangle -D PREROUTING -i %s -j MARK --set-mark %s" % ( tincname, table_in ), task ) host.execute ( "iptables -t mangle -D PREROUTING -i %s -j MARK --set-mark %s" % ( con.bridge_name(), table_out ... | def stop_run(self, task): generic.Connector.stop_run(self, task) for con in self.connections_all(): host = con.interface.device.host tincname = self.tincname(con) if self.type == "router": table_in = 1000 + 2 * con.id table_out = 1000 + 2 * con.id + 1 host.execute ( "iptables -t mangle -D PREROUTING -i %s -j MARK --set... |
task.subtasks_total = 5 | task.subtasks_total = 6 | def check_save(self, task): task.subtasks_total = 5 self.check(task) self.save() task.done() |
from util import run_shell | def check(self, task): """ Checks if the host is reachable, login works and the needed software is installed """ from util import run_shell task.output.write("checking for openvz...\n") task.output.write(run_shell (["ssh", "root@%s" % self.name, "vzctl --version" ], config.remote_dry_run)) task.subtasks_done = task.su... | |
task.output.write(run_shell (["ssh", "root@%s" % self.name, "vzctl --version" ], config.remote_dry_run)) | res = self.get_result("vzctl --version; echo $?") task.output.write(res) assert res.split("\n")[-2] == "0", "OpenVZ error" task.subtasks_done = task.subtasks_done + 1 task.output.write("checking for kvm...\n") res = self.get_result("qm list; echo $?") task.output.write(res) assert res.split("\n")[-2] == "0", "OpenVZ er... | def check(self, task): """ Checks if the host is reachable, login works and the needed software is installed """ from util import run_shell task.output.write("checking for openvz...\n") task.output.write(run_shell (["ssh", "root@%s" % self.name, "vzctl --version" ], config.remote_dry_run)) task.subtasks_done = task.su... |
task.output.write(run_shell (["ssh", "root@%s" % self.name, "brctl show" ], config.remote_dry_run)) | res = self.get_result("brctl --version; echo $?") task.output.write(res) assert res.split("\n")[-2] == "0", "brctl error" | def check(self, task): """ Checks if the host is reachable, login works and the needed software is installed """ from util import run_shell task.output.write("checking for openvz...\n") task.output.write(run_shell (["ssh", "root@%s" % self.name, "vzctl --version" ], config.remote_dry_run)) task.subtasks_done = task.su... |
task.output.write(run_shell (["ssh", "root@%s" % self.name, "ipfw -h" ], config.remote_dry_run)) | res = self.get_result("ipfw list; echo $?") task.output.write(res) assert res.split("\n")[-2] == "0", "dumynet error" | def check(self, task): """ Checks if the host is reachable, login works and the needed software is installed """ from util import run_shell task.output.write("checking for openvz...\n") task.output.write(run_shell (["ssh", "root@%s" % self.name, "vzctl --version" ], config.remote_dry_run)) task.subtasks_done = task.su... |
task.output.write(run_shell (["ssh", "root@%s" % self.name, "tincd --version" ], config.remote_dry_run)) | res = self.get_result("tincd --version; echo $?") task.output.write(res) assert res.split("\n")[-2] == "0", "tinc error" | def check(self, task): """ Checks if the host is reachable, login works and the needed software is installed """ from util import run_shell task.output.write("checking for openvz...\n") task.output.write(run_shell (["ssh", "root@%s" % self.name, "vzctl --version" ], config.remote_dry_run)) task.subtasks_done = task.su... |
cmd = ["ssh", "-oStrictHostKeyChecking=no", "root@%s" % self.name, command] | cmd = [Host.SSH_COMMAND, "root@%s" % self.name, command] | def execute(self, command, task=None): cmd = ["ssh", "-oStrictHostKeyChecking=no", "root@%s" % self.name, command] str = self.name + ": " + command + "\n" if task: fd = task.output else: fd = sys.stdout fd.write(str) res = self._exec(cmd) fd.write(res) return res |
cmd = ["rsync", "-a", local_file, "root@%s:%s" % (self.name, remote_file)] | cmd = [Host.RSYNC_COMMAND, local_file, "root@%s:%s" % (self.name, remote_file)] | def upload(self, local_file, remote_file, task=None): cmd = ["rsync", "-a", local_file, "root@%s:%s" % (self.name, remote_file)] str = self.name + ": " + local_file + " -> " + remote_file + "\n" self.execute("mkdir -p $(dirname %s)" % remote_file, task) if task: fd = task.output else: fd = sys.stdout fd.write(str) res... |
cmd = ["rsync", "-a", "root@%s:%s" % (self.name, remote_file), local_file] | cmd = [Host.RSYNC_COMMAND, "root@%s:%s" % (self.name, remote_file), local_file] | def download(self, remote_file, local_file, task=None): cmd = ["rsync", "-a", "root@%s:%s" % (self.name, remote_file), local_file] str = self.name + ": " + local_file + " <- " + remote_file + "\n" if task: fd = task.output else: fd = sys.stdout fd.write(str) res = self._exec(cmd) fd.write(res) return res |
return self._exec(["ssh", "-oStrictHostKeyChecking=no", "root@%s" % self.name, command]) | return self._exec([Host.SSH_COMMAND, "root@%s" % self.name, command]) | def get_result(self, command): return self._exec(["ssh", "-oStrictHostKeyChecking=no", "root@%s" % self.name, command]) |
self.host.execute("tar -xzvf %s -C /var/lib/vz/private/%s" % ( remote_filename, self.openvz_id ), task) | self.host.execute("mkdir /var/lib/vz/private/%s" % self.openvz_id, task) self.host.execute("tar -xzf %s -C /var/lib/vz/private/%s" % ( remote_filename, self.openvz_id ), task) | def upload_image(self, filename, task): task.subtasks_total=2 tmp_id = uuid.uuid1() remote_filename= "/tmp/glabnetman-%s" % tmp_id self.host.upload(filename, remote_filename, task) task.subtasks_done = task.subtasks_done + 1 self.host.execute("rm -rf /var/lib/vz/private/%s" % self.openvz_id, task) self.host.execute("ta... |
return self.get_result("[ -d /sys/class/net/%s/brif ]; echo $?" % bridge).split()[0] == "0" | return self._first_line(self.get_result("[ -d /sys/class/net/%s/brif ]; echo $?" % bridge)) == "0" | def bridge_exists(self, bridge): return self.get_result("[ -d /sys/class/net/%s/brif ]; echo $?" % bridge).split()[0] == "0" |
return self.get_result("[ -d /sys/class/net/%s/brport/bridge ] && basename $(readlink /sys/class/net/%s/brport/bridge)" % (iface, iface)).split()[0] | return self._first_line(self.get_result("[ -d /sys/class/net/%s/brport/bridge ] && basename $(readlink /sys/class/net/%s/brport/bridge)" % (iface, iface))) | def interface_bridge(self, iface): return self.get_result("[ -d /sys/class/net/%s/brport/bridge ] && basename $(readlink /sys/class/net/%s/brport/bridge)" % (iface, iface)).split()[0] |
return self.get_result("[ -d /sys/class/net/%s ]; echo $?" % iface).split()[0] == "0" | return self._first_line(self.get_result("[ -d /sys/class/net/%s ]; echo $?" % iface)) == "0" | def interface_exists(self, iface): return self.get_result("[ -d /sys/class/net/%s ]; echo $?" % iface).split()[0] == "0" |
cmd = ["ssh", "root@%s" % self.name, command] | cmd = ["ssh", "-oStrictHostKeyChecking=no", "root@%s" % self.name, command] | def execute(self, command, task=None): cmd = ["ssh", "root@%s" % self.name, command] str = self.name + ": " + command + "\n" if task: fd = task.output else: fd = sys.stdout fd.write(str) res = self._exec(cmd) fd.write(res) return res |
return self._exec(["ssh", "root@%s" % self.name, command]) | return self._exec(["ssh", "-oStrictHostKeyChecking=no", "root@%s" % self.name, command]) | def get_result(self, command): return self._exec(["ssh", "root@%s" % self.name, command]) |
if dom.hasAttribute("bridge_name"): dom.removeAttribute("bridge_name") | if dom.hasAttribute("bridge"): dom.removeAttribute("bridge") | def encode_xml (self, dom, doc, print_ids): """ Encode the object to an xml dom object @param dom the xml dom object to write the data to @param doc the xml document needed to create child elements @print_ids whether to include or ignore assigned ids """ XmlObject.encode_xml(self, dom) if not print_ids: if dom.hasAttri... |
if dom.hasAttribute("bridge_name"): dom.removeAttribute("bridge_name") | if dom.hasAttribute("bridge"): dom.removeAttribute("bridge") | def decode_xml (self, dom, load_ids): """ Read the attributes from the xml dom object @param dom the xml dom object to read the data from @load_ids whether to load or ignore assigned ids """ if not load_ids: if dom.hasAttribute("bridge_id"): dom.removeAttribute("bridge_id") if dom.hasAttribute("bridge_name"): dom.remov... |
self.gateway = util.get_attr(dom, "gateway", default=None) | self.gateway = util.get_attr(dom, "gateway", default="10.1.1.254/24") if not len(self.gateway.split("/")) == 2: self.gateway = self.gateway + "/24" | def decode_xml(self, dom): dummynet.EmulatedConnection.decode_xml(self, dom) self.gateway = util.get_attr(dom, "gateway", default=None) |
self.delay = util.get_attr(dom, "delay", default="0") self.bandwidth = util.get_attr(dom, "bandwidth", default="0") self.lossratio = util.get_attr(dom,"lossratio", default=0.0) | try: self.delay = int(util.get_attr(dom, "delay", default="0")) except: self.delay = 0 try: self.bandwidth = int(util.get_attr(dom, "bandwidth", default="0")) except: self.bandwidth = 10000 try: self.lossratio = float(util.get_attr(dom,"lossratio", default=0.0)) except: self.lossratio = 0.0 | def decode_xml(self, dom): generic.Connection.decode_xml(self, dom) self.delay = util.get_attr(dom, "delay", default="0") self.bandwidth = util.get_attr(dom, "bandwidth", default="0") self.lossratio = util.get_attr(dom,"lossratio", default=0.0) self.capture = util.parse_bool(util.get_attr(dom, "capture", default="false... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.