rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
will be disabled. | will be disabled for *observer*. * **observer** The specific observer to not send posts to. If no *observer* is given, the appropriate notifications will not be posted to any observers. | def disableNotificationsForObservable(self, observable, notification=None): """ Disable all notifications posted to all objects observing **notification** in **observable**. |
if notification is not None: key = (observable, notification) else: key = observable | if observer is not None: observer = weakref.ref(observer) key = self._makeDisableKey(observable, notification=notification, observer=observer) | def disableNotificationsForObservable(self, observable, notification=None): """ Disable all notifications posted to all objects observing **notification** in **observable**. |
def enableNotificationsForObservable(self, observable, notification=None): | def enableNotificationsForObservable(self, observable, notification=None, observer=None): | def enableNotificationsForObservable(self, observable, notification=None): """ Enable notifications posted to all objects observing **notification** in **observable**. |
if notification is not None: key = (observable, notification) else: key = observable | if observer is not None: observer = weakref.ref(observer) key = self._makeDisableKey(observable, notification=notification, observer=observer) | def enableNotificationsForObservable(self, observable, notification=None): """ Enable notifications posted to all objects observing **notification** in **observable**. |
def areNotificationsDisabledForObservable(self, observable, notification=None): | def areNotificationsDisabledForObservable(self, observable, notification=None, observer=None): | def areNotificationsDisabledForObservable(self, observable, notification=None): """ Returns a boolean indicating if notifications posted to all objects observing **notification** in **observable** are disabled. |
""" if (observable, notification) in self._disabled: return True return weakref.ref(observable) in self._disabled | * **observer** The observer. This is optional. """ observable = weakref.ref(observable) if observer is not None: observer = weakref.ref(observer) key = self._makeDisableKey(observable, notification=notification, observer=observer) return key in self._disabled def _makeDisableKey(self, observable, notification=None, ob... | def areNotificationsDisabledForObservable(self, observable, notification=None): """ Returns a boolean indicating if notifications posted to all objects observing **notification** in **observable** are disabled. |
os.startfile(image) | def main(): url = 'http://www.rp.edu.sg/staffdirectory/ShowImage.aspx?id=' student_id = raw_input("Student ID : ") name = raw_input("Name : ") name2 = name.upper().replace(' ', '%20') url = url + student_id + '-' + name2 + '.jpg' image = urllib2.urlopen(url).read() filename = name + '.jpg' f = open(filename, "wb") f.... | |
myGrades = PythonLeo("91178", "pyro1$cute") | myGrades = PythonLeo("12345", "UrPasswordGoesHere") | def get_module(from_url): #module = re.search('([A-Z]\d\d\d-[12348]-[WE]\d\d[A-Z]-[ABC])', from_url.read()) module = re.search('([A-Z]\d\d\d)', from_url.read()) return module.groups()[0] |
myGrades = PythonLeo.PythonLeo("12345", "urPasswordGoesHere") | myGrades = PythonLeo.PythonLeo("91178", "pyro1$cute") | def main(): url = 'http://leo.rp.edu.sg/workspace/studentGrades.asp' url2 = 'http://leo3.rp.edu.sg//projectweb/student_summary.asp?' myGrades = PythonLeo.PythonLeo("12345", "urPasswordGoesHere") #student ID & Password course_id_list = removeDuplicate(myGrades.parse_id("courseid", myGrades.open_url(url))) project_id_l... |
project_id_list = myGrades.parse_id("projectid", myGrades.open_url(url)) | def main(): url = 'http://leo.rp.edu.sg/workspace/studentGrades.asp' url2 = 'http://leo3.rp.edu.sg//projectweb/student_summary.asp?' myGrades = PythonLeo.PythonLeo("12345", "urPasswordGoesHere") #student ID & Password course_id_list = removeDuplicate(myGrades.parse_id("courseid", myGrades.open_url(url))) project_id_l... | |
url = url2 + 'course_id=' + course | url = url2 + 'courseid=' + course | def main(): url = 'http://leo.rp.edu.sg/workspace/studentGrades.asp' url2 = 'http://leo3.rp.edu.sg//projectweb/student_summary.asp?' myGrades = PythonLeo.PythonLeo("12345", "urPasswordGoesHere") #student ID & Password course_id_list = removeDuplicate(myGrades.parse_id("courseid", myGrades.open_url(url))) project_id_l... |
a=zfile.namelist() | zip_dirs=zfile.namelist() | def download(): response.set("Connecting") leo = PythonLeo.PythonLeo(username_field.get(),password_field.get()) #e.g. 91224, 12345 project_id_list = leo.parse_id("projectid",leo.open_url(URL_LIST["current_module"])) group_id_list = leo.parse_id("groupid",leo.open_url(URL_LIST["current_module"])) topic_id_list = leo.par... |
b=os.getcwd()+"/"+"Problem"+str(len(project_id_list))+"/" os.makedirs(b) | new_folder=os.getcwd()+"/"+"Problem"+str(len(project_id_list))+"/" os.makedirs(new_folder) | def download(): response.set("Connecting") leo = PythonLeo.PythonLeo(username_field.get(),password_field.get()) #e.g. 91224, 12345 project_id_list = leo.parse_id("projectid",leo.open_url(URL_LIST["current_module"])) group_id_list = leo.parse_id("groupid",leo.open_url(URL_LIST["current_module"])) topic_id_list = leo.par... |
for i in a: | for i in zip_dirs: | def download(): response.set("Connecting") leo = PythonLeo.PythonLeo(username_field.get(),password_field.get()) #e.g. 91224, 12345 project_id_list = leo.parse_id("projectid",leo.open_url(URL_LIST["current_module"])) group_id_list = leo.parse_id("groupid",leo.open_url(URL_LIST["current_module"])) topic_id_list = leo.par... |
filename=a[count][(a[count].rfind("/")+1)::] | filename=zip_dirs[count][(zip_dirs[count].rfind("/")+1)::] | def download(): response.set("Connecting") leo = PythonLeo.PythonLeo(username_field.get(),password_field.get()) #e.g. 91224, 12345 project_id_list = leo.parse_id("projectid",leo.open_url(URL_LIST["current_module"])) group_id_list = leo.parse_id("groupid",leo.open_url(URL_LIST["current_module"])) topic_id_list = leo.par... |
shutil.copyfile(extractDirectory,(b+"/"+filename)) | shutil.copyfile(extractDirectory,(new_folder+"/"+filename)) | def download(): response.set("Connecting") leo = PythonLeo.PythonLeo(username_field.get(),password_field.get()) #e.g. 91224, 12345 project_id_list = leo.parse_id("projectid",leo.open_url(URL_LIST["current_module"])) group_id_list = leo.parse_id("groupid",leo.open_url(URL_LIST["current_module"])) topic_id_list = leo.par... |
url = 'http://myrp.sg/SASS-Student/Photo/' myid = '91178' mypassword = 'pyro1$cute' | url = 'http://www.rp.edu.sg/staffdirectory/ShowImage.aspx?id=' | def main(): url = 'http://myrp.sg/SASS-Student/Photo/' myid = '91178' mypassword = 'pyro1$cute' student_id = raw_input("Student ID : ") name = raw_input("Name : ") name2 = name.upper().replace(' ', '%20') url = url + student_id + '-' + name2 + '.jpg' login = PythonLeo.PythonLeo(myid, mypassword) image = login.open_ur... |
login = PythonLeo.PythonLeo(myid, mypassword) image = login.open_url(url).read() | image = urllib2.urlopen(url).read() | def main(): url = 'http://myrp.sg/SASS-Student/Photo/' myid = '91178' mypassword = 'pyro1$cute' student_id = raw_input("Student ID : ") name = raw_input("Name : ") name2 = name.upper().replace(' ', '%20') url = url + student_id + '-' + name2 + '.jpg' login = PythonLeo.PythonLeo(myid, mypassword) image = login.open_ur... |
wcsMetadata = exposure.getWcs().getFitsMetadata() | wcsMetadata = item.getWcs().getFitsMetadata() | def _setWcs(self, item): md = item.getMetadata() item.setWcs(afwImage.makeWcs(md)) wcsMetadata = exposure.getWcs().getFitsMetadata() for kw in wcsMetadata.paramNames(): md.remove(kw) |
self.log = pexLog.Log(pexLog.getDefaultLog(), "CfhtMapper") | self.log = pexLog.Log(pexLog.getDefaultLog(), "LsstSimMapper") | def __init__(self, policy=None, root=".", registry=None, calibRoot=None): Mapper.__init__(self) |
return ButlerLocation(None, None, "PickleStorage", path, None) | return ButlerLocation(None, None, "PickleStorage", path, {}) | def map_satPixelSet(self, dataId): pathId = self._mapActualToPath(self._needFilter(dataId)) path = os.path.join(self.root, self.satPixelSetTemplate % pathId) return ButlerLocation(None, None, "PickleStorage", path, None) |
(int(r1) * 5 + int(r2)) * 10 + (int(s1) * 3 + int(s2)) | (long(r1) * 5 + long(r2)) * 10 + (long(s1) * 3 + long(s2)) | def map_src(self, dataId): pathId = self._mapActualToPath(self._needFilter(dataId)) path = os.path.join(self.root, self.srcTemplate % pathId) r1, r2 = dataId['raft'].split(',') s1, s2 = dataId['sensor'].split(',') ampExposureId = (dataId['visit'] << 9) + \ (int(r1) * 5 + int(r2)) * 10 + (int(s1) * 3 + int(s2)) return B... |
int(m.groups(1)), int(m.groups(2))) | int(m.group(1)), int(m.group(2))) | def extract_ampId(self, dataId): m = re.match(r'(\d)(\d)', dataId['channel']) return (self.extract_detectorName(dataId), int(m.groups(1)), int(m.groups(2))) |
pathId = self._mapActualToPath(_needFilter(dataId)) | pathId = self._mapActualToPath(self._needFilter(dataId)) | def map_satPixelSet(self, dataId): pathId = self._mapActualToPath(_needFilter(dataId)) path = os.path.join(self.root, self.satPixelSetTemplate % pathId) return ButlerLocation(None, None, "PickleStorage", path, None) |
ampId = self.convert_raftSensorChannel_to_ampId(dataId) detector = cameraGeomUtils.findAmp( self.camera, afwCameraGeom.Id(ampId[0]), ampId[1], ampId[2]) exposure.setDetector(detector) return exposure | ampId = self.extract_ampId(dataId) detector = cameraGeomUtils.findAmp( self.camera, afwCameraGeom.Id(ampId[0]), ampId[1], ampId[2]) item.setDetector(detector) return item | def std_bias(self, item, dataId): ampId = self.convert_raftSensorChannel_to_ampId(dataId) detector = cameraGeomUtils.findAmp( self.camera, afwCameraGeom.Id(ampId[0]), ampId[1], ampId[2]) exposure.setDetector(detector) return exposure |
ampId = self.convert_raftSensorChannel_to_ampId(dataId) detector = cameraGeomUtils.findAmp( self.camera, afwCameraGeom.Id(ampId[0]), ampId[1], ampId[2]) exposure.setDetector(detector) return exposure | ampId = self.extract_ampId(dataId) detector = cameraGeomUtils.findAmp( self.camera, afwCameraGeom.Id(ampId[0]), ampId[1], ampId[2]) item.setDetector(detector) return item | def std_dark(self, item, dataId): ampId = self.convert_raftSensorChannel_to_ampId(dataId) detector = cameraGeomUtils.findAmp( self.camera, afwCameraGeom.Id(ampId[0]), ampId[1], ampId[2]) exposure.setDetector(detector) return exposure |
ampId = self.convert_raftSensorChannel_to_ampId(dataId) detector = cameraGeomUtils.findAmp( self.camera, afwCameraGeom.Id(ampId[0]), ampId[1], ampId[2]) exposure.setDetector(detector) | ampId = self.extract_ampId(dataId) detector = cameraGeomUtils.findAmp( self.camera, afwCameraGeom.Id(ampId[0]), ampId[1], ampId[2]) item.setDetector(detector) | def std_flat(self, item, dataId): ampId = self.convert_raftSensorChannel_to_ampId(dataId) detector = cameraGeomUtils.findAmp( self.camera, afwCameraGeom.Id(ampId[0]), ampId[1], ampId[2]) exposure.setDetector(detector) |
exposure.setFilter(filter) | item.setFilter(filter) | def std_flat(self, item, dataId): ampId = self.convert_raftSensorChannel_to_ampId(dataId) detector = cameraGeomUtils.findAmp( self.camera, afwCameraGeom.Id(ampId[0]), ampId[1], ampId[2]) exposure.setDetector(detector) |
return exposure | return item | def std_flat(self, item, dataId): ampId = self.convert_raftSensorChannel_to_ampId(dataId) detector = cameraGeomUtils.findAmp( self.camera, afwCameraGeom.Id(ampId[0]), ampId[1], ampId[2]) exposure.setDetector(detector) |
ampId = self.convert_raftSensorChannel_to_ampId(dataId) detector = cameraGeomUtils.findAmp( self.camera, afwCameraGeom.Id(ampId[0]), ampId[1], ampId[2]) exposure.setDetector(detector) | ampId = self.extract_ampId(dataId) detector = cameraGeomUtils.findAmp( self.camera, afwCameraGeom.Id(ampId[0]), ampId[1], ampId[2]) item.setDetector(detector) | def std_fringe(self, item, dataId): ampId = self.convert_raftSensorChannel_to_ampId(dataId) detector = cameraGeomUtils.findAmp( self.camera, afwCameraGeom.Id(ampId[0]), ampId[1], ampId[2]) exposure.setDetector(detector) |
exposure.setFilter(filter) | item.setFilter(filter) | def std_fringe(self, item, dataId): ampId = self.convert_raftSensorChannel_to_ampId(dataId) detector = cameraGeomUtils.findAmp( self.camera, afwCameraGeom.Id(ampId[0]), ampId[1], ampId[2]) exposure.setDetector(detector) |
return exposure | return item | def std_fringe(self, item, dataId): ampId = self.convert_raftSensorChannel_to_ampId(dataId) detector = cameraGeomUtils.findAmp( self.camera, afwCameraGeom.Id(ampId[0]), ampId[1], ampId[2]) exposure.setDetector(detector) |
actualId['filter'] = str(rows[0][0]) | actualId['filter'] = rows[0][0] | def _needFilter(self, dataId): if dataId.has_key('filter'): return dataId actualId = dataId.copy() if not dataId.has_key('visit'): raise KeyError, \ "Data id missing visit key, cannot look up filter\n" + \ str(dataId) if not hasattr(self, 'registry') or self.registry is None: raise RuntimeError, "No registry available ... |
filterName = str(rows[0][0]) | filterName = rows[0][0] | def _setFilter(self, item, dataId): md = item.getMetadata() filterName = None if md.exists("FILTER"): filterName = item.getMetadata().get("FILTER").strip() if filterName is None: rows = self.registry.executeQuery(("filter",), ("raw",), {'visit': "?"}, None, (dataId['visit'],)) if len(rows) != 1: raise RuntimeError, \ "... |
wcsMetadata = item.getWcs().getFitsMetadata() | wcsMetadata = exposure.getWcs().getFitsMetadata() | def std_raw(self, item, dataId): exposure = afwImage.ExposureU( afwImage.makeMaskedImage(item.getImage())) md = item.getMetadata() exposure.setMetadata(md) exposure.setWcs(afwImage.makeWcs(md)) wcsMetadata = item.getWcs().getFitsMetadata() for kw in wcsMetadata.paramNames(): md.remove(kw) return self._standardizeExposu... |
pathId['raft'] = re.sub(r'R:(\d),(\d)', r'R\1\2', pathId['raft']) | pathId['raft'] = re.sub(r'R:(\d),(\d)', r'\1\2', pathId['raft']) | def _mapActualToPath(self, actualId): pathId = dict(actualId) if pathId.has_key("raft"): pathId['raft'] = re.sub(r'R:(\d),(\d)', r'R\1\2', pathId['raft']) if pathId.has_key("sensor"): pathId['sensor'] = re.sub(r'S:(\d),(\d)', r'S\1\2', pathId['sensor']) if pathId.has_key("channel"): pathId['channel'] = re.sub(r'C:(\d),... |
pathId['sensor'] = re.sub(r'S:(\d),(\d)', r'S\1\2', pathId['sensor']) if pathId.has_key("channel"): pathId['channel'] = re.sub(r'C:(\d),(\d)', r'C\1\2', pathId['channel']) | pathId['sensor'] = re.sub(r'S:(\d),(\d)', r'\1\2', pathId['sensor']) | def _mapActualToPath(self, actualId): pathId = dict(actualId) if pathId.has_key("raft"): pathId['raft'] = re.sub(r'R:(\d),(\d)', r'R\1\2', pathId['raft']) if pathId.has_key("sensor"): pathId['sensor'] = re.sub(r'S:(\d),(\d)', r'S\1\2', pathId['sensor']) if pathId.has_key("channel"): pathId['channel'] = re.sub(r'C:(\d),... |
id = m.groups(0) + m.groups(1) + m.groups(2) | id = m.groups(1) + m.groups(2) | def _mapActualToPath(self, actualId): pathId = dict(actualId) if pathId.has_key("raft"): pathId['raft'] = re.sub(r'R:(\d),(\d)', r'R\1\2', pathId['raft']) if pathId.has_key("sensor"): pathId['sensor'] = re.sub(r'S:(\d),(\d)', r'S\1\2', pathId['sensor']) if pathId.has_key("channel"): pathId['channel'] = re.sub(r'C:(\d),... |
m = re.search(r'raw/v(\d+)-f(\w)/E00(\d)/R(\d)(\d)/S(\d)(\d)/' + | m = re.search(r'v(\d+)-f(\w)/E00(\d)/R(\d)(\d)/S(\d)(\d)/' + | def processRaft(raftDir, conn, done, qsp): nProcessed = 0 nSkipped = 0 nUnrecognized = 0 for fits in glob.glob(os.path.join(raftDir, "S[0-2][0-2]", "imsim_*_R[0-4][0-4]_S[0-2][0-2]_C[01][0-7]_E00[01].fits*")): m = re.search(r'raw/v(\d+)-f(\w)/E00(\d)/R(\d)(\d)/S(\d)(\d)/' + r'imsim_\1_R\4\5_S\6\7_C(\d)(\d)_E00\3\.fits'... |
path = os.path.join(self.root, self.sourceHistTemplate % pathId) | path = os.path.join(self.root, self.sourceHistTemplate % dataId) | def map_sourceHist(self, dataId): dataId = self._transformId(dataId) path = os.path.join(self.root, self.sourceHistTemplate % pathId) return ButlerLocation( "lsst.afw.image.DecoratedImageU", "DecoratedImageU", "FitsStorage", path) |
path = os.path.join(self.root, self.badSourceHistTemplate % pathId) | path = os.path.join(self.root, self.badSourceHistTemplate % dataId) | def map_badSourceHist(self, dataId): dataId = self._transformId(dataId) path = os.path.join(self.root, self.badSourceHistTemplate % pathId) return ButlerLocation( "lsst.afw.image.DecoratedImageU", "DecoratedImageU", "FitsStorage", path) |
path = os.path.join(self.root, self.sourceTemplate % pathId) | path = os.path.join(self.root, self.sourceTemplate % dataId) | def map_source(self, dataId): dataId = self._transformId(dataId) path = os.path.join(self.root, self.sourceTemplate % pathId) return ButlerLocation( "lsst.afw.detection.PersistableSourceVector", "PersistableSourceVector", "BoostStorage", path) |
path = os.path.join(self.root, self.badSourceTemplate % pathId) | path = os.path.join(self.root, self.badSourceTemplate % dataId) | def map_badSource(self, dataId): dataId = self._transformId(dataId) path = os.path.join(self.root, self.badSourceTemplate % pathId) return ButlerLocation( "lsst.afw.detection.PersistableSourceVector", "PersistableSourceVector", "BoostStorage", path) |
path = os.path.join(self.root, self.invalidSourceHistTemplate % pathId) | path = os.path.join(self.root, self.invalidSourceHistTemplate % dataId) | def map_invalidSource(self, dataId): dataId = self._transformId(dataId) path = os.path.join(self.root, self.invalidSourceHistTemplate % pathId) return ButlerLocation( "lsst.afw.detection.PersistableSourceVector", "PersistableSourceVector", "BoostStorage", path) |
path = os.path.join(self.root, self.objectTemplate % pathId) | path = os.path.join(self.root, self.objectTemplate % dataId) | def map_object(self, dataId): dataId = self._transformId(dataId) path = os.path.join(self.root, self.objectTemplate % pathId) return ButlerLocation( "lsst.ap.cluster.PersistableSourceClusterVector", "PersistableSourceClusterVector", "BoostStorage", path) |
path = os.path.join(self.root, self.badObjectTemplate % pathId) | path = os.path.join(self.root, self.badObjectTemplate % dataId) | def map_badObject(self, dataId): dataId = self._transformId(dataId) path = os.path.join(self.root, self.badObjectTemplate % pathId) return ButlerLocation( "lsst.ap.cluster.PersistableSourceClusterVector", "PersistableSourceClusterVector", "BoostStorage", path) |
refCoord = afwCoord.Fk5Coord(origin[0], origin[1], epoch) | refCoord = afwCoord.Fk5Coord( origin.getLongitude(afwCoord.DEGREES), origin.getLatitude(afwCoord.DEGREES), epoch) | def std_raw(self, item, dataId): dataId = self._transformId(dataId) exposure = afwImage.makeExposure( afwImage.makeMaskedImage(item.getImage())) md = item.getMetadata() exposure.setMetadata(md) wcs = afwImage.makeWcs(md) |
wcs = exposure.getWcs() | wcs = item.getWcs() | def _standardizeExposure(self, item, dataId, isAmp=False): md = item.getMetadata() stripFits(md) |
self.root = self.policy.getString('calibRoot') | self.calibRoot = self.policy.getString('calibRoot') | def __init__(self, policy=None, root=".", calibRoot=None): Mapper.__init__(self) |
setattr(MinMapper, "map_" + calibType, lambda self, dataId: | setattr(LsstSimMapper, "map_" + calibType, lambda self, dataId: | def _calibMapper(self, datasetType, dataId): pathId = self._mapActualToPath(self._mapIdToActual(dataId)) path = os.path.join(self.calibRoot, getattr(self, datasetType + 'Template') % pathId) return ButlerLocation( "lsst.afw.image.ExposureU", "ExposureU", "FitsStorage", path, dataId) |
def map_raw(self, datasetType, root, dataId): | def map_raw(self, dataId): | def map_raw(self, datasetType, root, dataId): pathId = self._mapActualToPath(self._mapIdToActual(dataId)) path = os.path.join(self.root, rawTemplate % pathId) return ButlerLocation( "lsst.afw.image.DecoratedImageU", "DecoratedImageU", "FitsStorage", path, dataId) |
raise pexExcept.LsstException, "Registry not found" self.registry = SqliteRegistry(registryPath) self.keys = self.registry.getFields() | pass if registryPath is not None: self.registry = SqliteRegistry(registryPath) self.keys = ["visit", "raft", "sensor", "channel", "snap"] | def __init__(self, policy=None, root=".", calibRoot=None): Mapper.__init__(self) |
raise pexExcept.LsstException, "Calibration registry not found" self.calibRegistry = SqliteRegistry(calibRegistryPath) for k in self.calibRegistry.getFields(): if k not in self.keys: self.keys.append(k) | pass if calibRegistryPath is not None: self.calibRegistry = SqliteRegistry(calibRegistryPath) self.keys.append("filter") | def __init__(self, policy=None, root=".", calibRoot=None): Mapper.__init__(self) |
def setUpDebug(test): setUp(test) zc.buildout.testing.install('zope.app.debug', test) | def setUp(test): zc.buildout.testing.buildoutSetUp(test) zc.buildout.testing.install('Paste', test) zc.buildout.testing.install('PasteDeploy', test) zc.buildout.testing.install('PasteScript', test) zc.buildout.testing.install('ZConfig', test) zc.buildout.testing.install('ZODB3', test) zc.buildout.testing.install('pytz'... | |
options['eggs'] = buildout[self.app]['eggs'] | options['eggs'] = '%s\nz3c.recipe.paster' % buildout[self.app]['eggs'] | def __init__(self, buildout, name, options): self.app = None self.buildout = buildout self.name = name self.options = options options['script'] = os.path.join(buildout['buildout']['bin-directory'], options.get('script', self.name), ) if options.get('app') is None: raise zc.buildout.UserError( 'You have to define at the... |
post_save(save_callback) post_delete(delete_callback) | post_save.connect(save_callback) post_delete.connect(delete_callback) | def save_callback(sender, instance, signal, *args, **kwargs): Log.content="object '%s' is created" % instance if ‘created’ not in kwargs: if not kwargs['created']: Log.content="object '%s' is edited" % instance Log.save() |
return '%d %s' % (self.priority, self.content) | return '%d %s in %s' % (self.priority, self.content, self.date) | def __unicode__(self): return '%d %s' % (self.priority, self.content) |
p.add_option("-i","--include", dest="svc_include", help="Services to include into monitoring") p.add_option("-e","--exclude", dest="svc_exclude", help="Services to exclude from monitoring") | p.add_option("-i","--include", dest="svc_include", help="Regular expression for service(s) to include into monitoring") p.add_option("-e","--exclude", dest="svc_exclude", help="Regular expression for service(s) to exclude from monitoring") | def main(): global opts, svc_includere, svc_excludere p = OptionParser() p.add_option("-H","--host", dest="host", help="Hostname or IP address") p.add_option("-p","--port", dest="port", type="int", default=2812, help="Port (Default: %default)") p.add_option("-s","--ssl", dest="ssl", action="store_true", default=False, ... |
outfile.write(str(p)+','+str(round(rand(xmin,xmax), 5))+','+\ str(round(rand(ymin,ymax), 5))+','+str(round(rand(zmin,zmax), 5))+\ ',0,0,0,0,0,0,0\n') | outfile.write(\ non_exp_repr(p)+','+\ non_exp_repr(round(rand(xmin,xmax), 5))+','+\ non_exp_repr(round(rand(ymin,ymax), 5))+','+\ non_exp_repr(round(rand(zmin,zmax), 5))+\ ',0,0,0,0,0,0,0\n') | def rand(low, high): return (random.random() * (high-low)) + low |
if value: | if value is not None: | def __iter__(self): for item in self.previous: pathkey = self.pathkey(*item.keys())[0] |
if value.lower()=='true': | if isinstance(value, bool): field.set(field.interface(obj), value) elif value.lower()=='true': | def __iter__(self): for item in self.previous: pathkey = self.pathkey(*item.keys())[0] |
v = filter( lambda p: not not p, [p.strip() for p in value.split(';')]) field.set(field.interface(obj), v) | if not isinstance(value, list): value = filter( lambda p: not not p, [p.strip() for p in value.split(';')]) field.set(field.interface(obj), value) | def __iter__(self): for item in self.previous: pathkey = self.pathkey(*item.keys())[0] |
value = datetime.strptime(value, "%d.%m.%Y") value = date( value.year, value.month, value.day) | try: value = datetime.strptime(value, "%d.%m.%Y") value = date( value.year, value.month, value.day) except ValueError: continue | def __iter__(self): for item in self.previous: pathkey = self.pathkey(*item.keys())[0] |
dispatch[UnicodeType] = write_string | def write_unicode(self, value): try: svalue = str(value) except UnicodeDecodeError: print "Error translating string to ASCII: %s"%value raise self.write('S') self.write(pack('>H', len(svalue))) self.write(svalue) dispatch[UnicodeType] = write_unicode | def write_string(self, value): |
def generateReplicaThreddsCatalog(mapfile, operation, sourceCatalogDictionary, sourceGateway=None, datasetId=None, offline=False, service=None, comment=None, version=None, project=None): | def generateReplicaThreddsCatalog(mapfile, operation, sourceCatalogDictionary, sourceGateway=None, datasetId=None, offline=False, service=None, comment=None, version=None, project=None, readFiles=False): | def generateReplicaThreddsCatalog(mapfile, operation, sourceCatalogDictionary, sourceGateway=None, datasetId=None, offline=False, service=None, comment=None, version=None, project=None): """ Scan a collection of files as defined in a mapfile, and generate THREDDS catalogs of the resulting datasets. A dictionary of cata... |
esgpublishWrapper(datasetMapfile=mapfile, publishOp=operation, masterGateway=sourceGateway, datasetName=datasetId, offline=offline, service=service, message=comment, thredds=True, las=False, publish=False, threddsCatalogDictionary=resultThreddsDictionary, version=version, reinitThredds=False, projectName=project, readF... | esgpublishWrapper(datasetMapfile=mapfile, publishOp=operation, masterGateway=sourceGateway, datasetName=datasetId, offline=offline, service=service, message=comment, thredds=True, las=False, publish=False, threddsCatalogDictionary=resultThreddsDictionary, version=version, reinitThredds=False, projectName=project, readF... | def generateReplicaThreddsCatalog(mapfile, operation, sourceCatalogDictionary, sourceGateway=None, datasetId=None, offline=False, service=None, comment=None, version=None, project=None): """ Scan a collection of files as defined in a mapfile, and generate THREDDS catalogs of the resulting datasets. A dictionary of cata... |
form = AIn7MemberForm(request.POST, instance=ain7member) | form = AIn7MemberForm(request.POST, request.FILES, instance=ain7member) | def ain7member_edit(request, user_id): is_myself = int(request.user.id) == int(user_id) access = check_access(request, request.user, ['ain7-secretariat','ain7-ca']) if access and not is_myself: return access person = get_object_or_404(Person, user=user_id) ain7member = get_object_or_404(AIn7Member, person=person) fo... |
filter = annuaire_search_engine().unregistered_filters(request.user.person) if filter: | search_filter = annuaire_search_engine().unregistered_filters(request.user.person) if search_filter: | def advanced_search(request): access = check_access(request, request.user, ['ain7-membre','ain7-secretariat']) if access: return access filter = annuaire_search_engine().unregistered_filters(request.user.person) if filter: return ain7_render_to_response(request, 'annuaire/adv_search.html', dict_for_filter(request, fi... |
dict_for_filter(request, filter.id)) | dict_for_filter(request, search_filter.id)) | def advanced_search(request): access = check_access(request, request.user, ['ain7-membre','ain7-secretariat']) if access: return access filter = annuaire_search_engine().unregistered_filters(request.user.person) if filter: return ain7_render_to_response(request, 'annuaire/adv_search.html', dict_for_filter(request, fi... |
filter = annuaire_search_engine().unregistered_filters(request.user.person) if not filter: | search_filter = annuaire_search_engine().unregistered_filters(request.user.person) if not search_filter: | def filter_new(request): access = check_access(request, request.user, ['ain7-membre','ain7-secretariat']) if access: return access filter = annuaire_search_engine().unregistered_filters(request.user.person) if not filter: return HttpResponseRedirect('/annuaire/advanced_search/') remove_criteria(request, filter) if fi... |
remove_criteria(request, filter) if filter.registered: | remove_criteria(request, search_filter) if search_filter.registered: | def filter_new(request): access = check_access(request, request.user, ['ain7-membre','ain7-secretariat']) if access: return access filter = annuaire_search_engine().unregistered_filters(request.user.person) if not filter: return HttpResponseRedirect('/annuaire/advanced_search/') remove_criteria(request, filter) if fi... |
'/annuaire/advanced_search/filter/%s/' % filter.id) | '/annuaire/advanced_search/filter/%s/' % search_filter.id) | def filter_new(request): access = check_access(request, request.user, ['ain7-membre','ain7-secretariat']) if access: return access filter = annuaire_search_engine().unregistered_filters(request.user.person) if not filter: return HttpResponseRedirect('/annuaire/advanced_search/') remove_criteria(request, filter) if fi... |
user_groups = request.user.groups.all().values_list('name', flat=True) | user_groups = request.user.person.groups.values_list('group__name', flat=True) | def index(request): """index adhesions""" count_subscribers = Subscription.objects.filter(validated=True).exclude(\ start_year__gt=datetime.date.today().year).exclude(\ end_year__lt=datetime.date.today().year).count() if not request.user.is_authenticated(): return HttpResponseRedirect('/accounts/login/?next=' + \ reve... |
del schema['lines']['lines']['taskline']['product_id'] | if doctype != 'estimation': del schema['lines']['lines']['taskline']['product_id'] | def remove_admin_fields(schema, kw): if kw['request'].user.is_contractor(): # Non admin users doesn't edit products del schema['lines']['lines']['taskline']['product_id'] schema['lines']['lines'].is_admin = False schema['lines']['lines']['taskline']['description'].css_class = 'span4' schema['lines']['lines']['taskline'... |
schema['lines']['lines']['taskline']['description'].css_class = 'span3' schema['lines']['lines']['taskline']['description'].widget.css_class = 'span3' schema['lines']['lines']['taskline']['tva'].css_class = 'span1' schema['lines']['lines']['taskline']['tva'].widget.css_class = 'span1' | if doctype != 'estimation': schema['lines']['lines']['taskline']['description'].css_class = 'span3' schema['lines']['lines']['taskline']['description'].widget.css_class = 'span3' schema['lines']['lines']['taskline']['tva'].css_class = 'span1' schema['lines']['lines']['taskline']['tva'].widget.css_class = 'span1' else: ... | def remove_admin_fields(schema, kw): if kw['request'].user.is_contractor(): # Non admin users doesn't edit products del schema['lines']['lines']['taskline']['product_id'] schema['lines']['lines'].is_admin = False schema['lines']['lines']['taskline']['description'].css_class = 'span4' schema['lines']['lines']['taskline'... |
values = [unicode(x, enc) for x in values] | values = [unicode(x, enc) for x in values if type(x) != type(u'')] | def getSubjectVocab(self): """Get subject (keywords) vocabulary""" catalog = getToolByName(self, 'portal_catalog') values = catalog.uniqueValuesFor('Subject') enc = getSiteEncoding(self) values = [unicode(x, enc) for x in values] return values |
print 'static const char *builtin_' + k + ' =' | print 'static const char builtin_' + k + '[] =' | def write_function_definitions(): fs = get_builtin_definitions() for k, v in sorted(fs.iteritems()): print 'static const char *builtin_' + k + ' =' print stringify(v), ';' |
print 'static const char *prototypes_for_' + profile + ' =' | print 'static const char prototypes_for_' + profile + '[] =' | def write_profile(filename, profile): (proto_ir, returncode) = run_compiler([filename]) if returncode != 0: print '#error builtins profile', profile, 'failed to compile' return # Kill any global variable declarations. We don't want them. kill_globals = re.compile(r'^\(declare.*\n', re.MULTILINE); proto_ir = kill_glo... |
print "TX: %r" % data | def sendall(self, data): """Our owm implementation of sendall(), since PyBlueZ doesn't have it on Windows hosts. """ print "TX: %r" % data while data and self.running: ret = self.sendFn(data[:MAX_SEND_SIZE]) assert ret > 0 data = data[ret:] | |
print "RX: %r" % buf | def run(self): buf = '' | |
log_message("%s (%d) plays %s (%d) on %s" % ( | log_message("%s (%d, %d) plays %s (%d, %d) on %s" % ( | def add_matches(cursor, max_matches, pairing_cutoff): ranked, unranked, paired = get_submissions(cursor) total_ranking = get_total_ranking(cursor, ranked, unranked) if pairing_cutoff: pairing_cutoff = max(pairing_cutoff - paired, 0) total_ranking = total_ranking[:pairing_cutoff] log_message("After cutoff %d available f... |
subprocess.Popen(shlex.split(cmd)).wait() | subprocess.Popen(args).wait() | def main(): signal.signal(signal.SIGINT, handler) qemu_identfile = "../sadbox/sshkey/vmkey" dest_path = "contestvm@localhost:~" try: opts, args = getopt.getopt(sys.argv[1:], "d:c:s:", ["directory=", "command=", "security="]) except getopt.GetoptError, err: sys.stderr.write( str(err) ) usage() sys.exit(2) sadbox_path = ... |
{"path" : player_two_path, "command" : player_two["command"], "submission_id": player_one["submission_id"]} | {"path" : player_two_path, "command" : player_two["command"], "submission_id": player_two["submission_id"]} | def record_game(self, data): url = self.base_url+'/api_record_game.php' url += '?api_key=%s' % self.api_key print urllib.urlopen(url,json.dumps(data)).read() |
"Lisp" : (".sbcl", [BOT, BOT + ".sbcl"], | "Lisp" : ("", [BOT], | def compile(self, globs, log): sources = safeglob_multi(globs) for source in sources: head, ext = os.path.splitext(source) if ext in self.replacements: target = head + self.replacements[ext] else: log.err += "Could not determine target for source file %s.\n" % source return False if not system(self.args + [self.outflag... |
dir_name = "" | dir_names = [] | def unpack(): out = "" err = "" zip_files = [ ("entry.tar.gz", "tar xfz"), ("entry.tgz", "tar xfz"), ("entry.zip", "unzip -u") ] found_archive_file = False for file in zip_files: file_name = file[0] command = file[1] + " " + file[0] + " > /dev/null 2> /dev/null" if os.path.exists(file_name): out += "Found " + file_name... |
num_dirs += 1 dir_name = file if num_dirs == 1 and num_files == 1: os.system("mv " + str(dir_name) + "/* .") os.system("rm -rf " + str(dir_name)) | dir_names.append(file) if len(dir_names) > 0 and num_files == 1: for dir_name in dir_names: os.system("mv " + str(dir_name) + "/* .") os.system("rm -rf " + str(dir_name)) | def unpack(): out = "" err = "" zip_files = [ ("entry.tar.gz", "tar xfz"), ("entry.tgz", "tar xfz"), ("entry.zip", "unzip -u") ] found_archive_file = False for file in zip_files: file_name = file[0] command = file[1] + " " + file[0] + " > /dev/null 2> /dev/null" if os.path.exists(file_name): out += "Found " + file_name... |
(p.X(), p.Y(), p.Owner(), p.NumShips(), p.GrothRate()) | (p.X(), p.Y(), p.Owner(), p.NumShips(), p.GrowthRate()) | def ToString(self): s = '' for p in self._planets: s += "P %f %f %d %d %d\n" % \ (p.X(), p.Y(), p.Owner(), p.NumShips(), p.GrothRate()) for f in self._fleets: s += "F %d %d %d %d %d %d\n" % \ (f.Owner(), f.NumShips(), f.SourcePlanet(), f.DestinationPlanet(), \ f.TotalTripLength(), f.TurnsRemaining()) return s |
os.system("sudo -H -u %s rm -rf /home/%s/*" % (self.jail_username, self.jail_username)) | os.system('sudo -H -u %s sh -c "rm -rf /home/%s/*"' % (self.jail_username, self.jail_username)) | def __init__(self, working_directory, shell_command, security_on): self.is_alive = False self.command_process = None self.stdout_queue = Queue() self.jail_username = None if security_on: self.jail_username = lock_jail_user() if self.jail_username is None: sys.stderr.write("No open jail users") return os.system("sudo -H... |
qemu_process.poll | qemu_process.poll() | def launch_qemu(): img_name = "test.img" qemu_port = 5555 qemu_cmd = "/usr/bin/qemu " + img_name + " -net nic -net user,hostfwd=tcp:127.0.0.1:" + str(qemu_port) + "-:22 -nographic" qemu_args = shlex.split(qemu_cmd) print "spinning up qemu instance" qemu_process = subprocess.Popen(qemu_args, stdin=subprocess.PIPE, stdou... |
if language == "Ocaml": | if language == "OCaml": | def compile_function(language): if language == "Java": out_message = "" err_message = "" nukeglob('*.class') nukeglob('*.jar') sources = safeglob('*.java') out, err = system(['javac'] + sources) out_message += out err_message += err out, err = system(['jar', 'cfe', 'MyBot.jar', 'MyBot'] + \ safeglob('*.class')) out_mes... |
out, err = system(['sbcl', '--end-runtime-options', '--no-sysinit', '--no-userinit', '--disable-debugger', '--load MyBot.lisp', '--eval', "(save-lisp-and-die \"MyBot\" :executable t :toplevel | out, err = system(['sbcl', '--end-runtime-options', '--no-sysinit', '--no-userinit', '--disable-debugger', '--load', 'MyBot.lisp', '--eval', "(save-lisp-and-die \"MyBot\" :executable t :toplevel | def compile_function(language): if language == "Java": out_message = "" err_message = "" nukeglob('*.class') nukeglob('*.jar') sources = safeglob('*.java') out, err = system(['javac'] + sources) out_message += out err_message += err out, err = system(['jar', 'cfe', 'MyBot.jar', 'MyBot'] + \ safeglob('*.class')) out_mes... |
if prev_num > cur_num * 0.99: | if prev_num * 0.99 > cur_num: | def get_submissions(cursor): cursor.execute("""SELECT leaderboard_id, timestamp FROM leaderboards WHERE leaderboard_id = (SELECT MAX(leaderboard_id) from leaderboards)""") row = cursor.fetchone() leaderboard_id = row['leaderboard_id'] log_message("latest leaderboard is %d" % leaderboard_id) # check that the latest lead... |
if cursor.rowcount > 0: | count = cursor.fetchone()['count(1)'] if count > 0: | def main(map_dir): map_files = os.listdir(map_dir) map_files = [m for m in map_files if m.startswith("map") and m.endswith(".txt")] connection = MySQLdb.connect(host = server_info["db_host"], user = server_info["db_username"], passwd = server_info["db_password"], db = server_info["db_name"]) cursor = connection.cursor(... |
values.append((os.path.splitext(map)[0], map, '1')) | values.append((os.path.splitext(map)[0], map, 1)) | def main(map_dir): map_files = os.listdir(map_dir) map_files = [m for m in map_files if m.startswith("map") and m.endswith(".txt")] connection = MySQLdb.connect(host = server_info["db_host"], user = server_info["db_username"], passwd = server_info["db_password"], db = server_info["db_name"]) cursor = connection.cursor(... |
values = ["("+",".join(v)+")" for v in values] values = "("+",".join(values)+")" | values = ["('%s','%s','%s')" % (n,m,p) for n,m,p in values] values = ",".join(values) | def main(map_dir): map_files = os.listdir(map_dir) map_files = [m for m in map_files if m.startswith("map") and m.endswith(".txt")] connection = MySQLdb.connect(host = server_info["db_host"], user = server_info["db_username"], passwd = server_info["db_password"], db = server_info["db_name"]) cursor = connection.cursor(... |
max_priority = _SERVER_MAPS[map_id] | high_priority = _SERVER_MAPS[map_id] | def choose_map(cursor, player1, player2): global _SERVER_MAPS if not _SERVER_MAPS: cursor.execute("SELECT map_id, priority FROM maps") _SERVER_MAPS = {} for row in cursor.fetchall(): if row['priority'] > 0: _SERVER_MAPS[row['map_id']] = row['priority'] p1_id = player1['submission_id'] p2_id = player2['submission_id'] c... |
def rand_radius(min, max): return ( math.sqrt(random.random()) * (max-min) ) + min | def rand_radius(min_r, max_r): val = min_r - 1 while val < min_r: val = math.sqrt(random.random()) * max_r return val | def rand_radius(min, max): return ( math.sqrt(random.random()) * (max-min) ) + min |
num_ships = random.randint(minShips, 5*distance(p1, p2)-1) | planet_max = min(100, 5 * distance(p1, p2) - 1) num_ships = random.randint(minShips, planet_max) | def not_valids(p1): for p in planets: adist = actual_distance(p, p1) if distance(p, p1) < minDistance or abs(adist-round(adist)) < epsilon: return True return False |
print scp_cmd | sys.stderr.write( scp_cmd) | def copy_exec_dir(qemu_port, qemu_identfile, sadbox_path, dest_path): scp_cmd = "scp -r -P " + str(qemu_port) + " -i " + qemu_identfile + " " + sadbox_path + " " + dest_path print scp_cmd scp_args = shlex.split(scp_cmd) scp_process = subprocess.Popen(scp_args, close_fds=True) print "copying files to instance" scp_proce... |
print "copying files to instance" | sys.stderr.write( "copying files to instance") | def copy_exec_dir(qemu_port, qemu_identfile, sadbox_path, dest_path): scp_cmd = "scp -r -P " + str(qemu_port) + " -i " + qemu_identfile + " " + sadbox_path + " " + dest_path print scp_cmd scp_args = shlex.split(scp_cmd) scp_process = subprocess.Popen(scp_args, close_fds=True) print "copying files to instance" scp_proce... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.