rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
super(SSLTransportWithCert, self).__init__(host, connect_timeout): | super(SSLTransportWithCert, self).__init__(host, connect_timeout) | def __init__(self, host, connect_timeout, ssl_cert=None, ssl_key=None): super(SSLTransportWithCert, self).__init__(host, connect_timeout): self.ssl_cert = ssl_cert self.ssl_key = ssl_key |
original_create_transport = create_transport | original_create_transport = transport.create_transport | def _setup_transport(self): if transport.HAVE_PY26_SSL: self.sslobj = ssl.wrap_socket(self.sock, keyfile=self.ssl_key, certfile=self.ssl_cert) self.sslobj.do_handshake() else: self.sslobj = socket.ssl(self.sock, keyfile=self.ssl_key, certfile=self.ssl_cert) |
os.environ.setdefault('IRGSH_NODE_COFNIG', 'irgsh-node.conf') | os.environ.setdefault('IRGSH_NODE_CONFIG', 'irgsh-node.conf') | def main(): import amqplib_sslcert_patch amqplib_sslcert_patch.use_configured_cert() os.environ.setdefault('IRGSH_NODE_COFNIG', 'irgsh-node.conf') os.environ.setdefault('CELERY_LOADER', 'irgsh_node.loader.IrgshNodeLoader') from celery.bin import celeryd celeryd.main() |
if (line[1] == "PRIVMSG") and (line[2] == CHANNEL) and (line[3][1:] == "!info"): sendchannel("Das Scherbengericht verbannt bzw. ernennt zum König, wer von %d oder mehr der Anwesenden gewählt wird." % (int(round(len(users)*VOTEQUOTA)))) | if (line[1] == "PRIVMSG") and (line[2] == CHANNEL) and \ (line[3][1:] == "!info"): sendchannel("Das Scherbengericht verbannt bzw. ernennt zum \ König, wer von %d oder mehr der Anwesenden gewählt wird." % \ (int(round(len(users) * VOTEQUOTA)))) | def checkTimeOut(votes): if votes[0][1] + TIMEOUT > time(): return votes # no votes have timed out elif len(votes) > 1: return checkTimeOut(votes[1:]) # oldest vote has timed out, continue checking else: return [] # no valid vote left |
if (line[1] == "PRIVMSG") and (line[2] == CHANNEL) and (len(line) >= 5): | if (line[1] == "PRIVMSG") and (line[2] == CHANNEL) and \ (len(line) >= 5): | def checkTimeOut(votes): if votes[0][1] + TIMEOUT > time(): return votes # no votes have timed out elif len(votes) > 1: return checkTimeOut(votes[1:]) # oldest vote has timed out, continue checking else: return [] # no valid vote left |
if user in (u for u,t in hatevotes[target]): sendchannel("Du hast bereits gegen %s abgestimmt." % (target)) | if user in (u for u, t in hatevotes[target]): sendchannel("Du hast bereits gegen %s abgestimmt." % \ (target)) | def checkTimeOut(votes): if votes[0][1] + TIMEOUT > time(): return votes # no votes have timed out elif len(votes) > 1: return checkTimeOut(votes[1:]) # oldest vote has timed out, continue checking else: return [] # no valid vote left |
hatevotes[target].append((user,time())) difference = int(round(len(users)*VOTEQUOTA)) - len(hatevotes[target]) | hatevotes[target].append((user, time())) difference = int(round(len(users) * VOTEQUOTA)) - \ len(hatevotes[target]) | def checkTimeOut(votes): if votes[0][1] + TIMEOUT > time(): return votes # no votes have timed out elif len(votes) > 1: return checkTimeOut(votes[1:]) # oldest vote has timed out, continue checking else: return [] # no valid vote left |
sendchannel("Stimme gegen %s gezählt. Noch %d Stimmmen nötig für Bann." % (target, difference)) | sendchannel("Stimme gegen %s gezählt. Noch %d \ Stimmmen nötig für Bann." % (target, difference)) | def checkTimeOut(votes): if votes[0][1] + TIMEOUT > time(): return votes # no votes have timed out elif len(votes) > 1: return checkTimeOut(votes[1:]) # oldest vote has timed out, continue checking else: return [] # no valid vote left |
sendchannel("Stimme gegen %s gezählt. Zuständige Stellen sind verständigt." % (target)) | sendchannel("Stimme gegen %s gezählt. \ Zuständige Stellen sind verständigt." % (target)) | def checkTimeOut(votes): if votes[0][1] + TIMEOUT > time(): return votes # no votes have timed out elif len(votes) > 1: return checkTimeOut(votes[1:]) # oldest vote has timed out, continue checking else: return [] # no valid vote left |
else: sendchannel("Abstimmung gegen %s anberaumt. Noch %d Stimmmen nötig für Bann." % (target, int(round(len(users)*VOTEQUOTA)) - 1)) hatevotes[target] = [(user,time())] | else: sendchannel("Abstimmung gegen %s anberaumt. Noch %d \ Stimmen nötig für Bann." % \ (target, int(round(len(users) * VOTEQUOTA)) - 1)) hatevotes[target] = [(user, time())] | def checkTimeOut(votes): if votes[0][1] + TIMEOUT > time(): return votes # no votes have timed out elif len(votes) > 1: return checkTimeOut(votes[1:]) # oldest vote has timed out, continue checking else: return [] # no valid vote left |
if len(hatevotes[nickname]) >= (int(round(len(users)*VOTEQUOTA))): | if len(hatevotes[nickname]) >= \ (int(round(len(users) * VOTEQUOTA))): | def checkTimeOut(votes): if votes[0][1] + TIMEOUT > time(): return votes # no votes have timed out elif len(votes) > 1: return checkTimeOut(votes[1:]) # oldest vote has timed out, continue checking else: return [] # no valid vote left |
if (command == "!für" or command == "!fuer" or command == u"!für".encode('latin_1')): if target in lovevotes.keys(): | if (command == "!für" or command == "!fuer" or \ command == u"!für".encode('latin_1')): if target in lovevotes.keys(): | def checkTimeOut(votes): if votes[0][1] + TIMEOUT > time(): return votes # no votes have timed out elif len(votes) > 1: return checkTimeOut(votes[1:]) # oldest vote has timed out, continue checking else: return [] # no valid vote left |
if user in (u for u,t in lovevotes[target]): sendchannel("Du hast bereits für %s abgestimmt." % (target)) | if user in (u for u, t in lovevotes[target]): sendchannel("Du hast bereits für %s abgestimmt." % \ (target)) | def checkTimeOut(votes): if votes[0][1] + TIMEOUT > time(): return votes # no votes have timed out elif len(votes) > 1: return checkTimeOut(votes[1:]) # oldest vote has timed out, continue checking else: return [] # no valid vote left |
lovevotes[target].append((user,time())) difference = int(round(len(users)*VOTEQUOTA)) - len(lovevotes[target]) | lovevotes[target].append((user, time())) difference = int(round(len(users) * VOTEQUOTA)) - \ len(lovevotes[target]) | def checkTimeOut(votes): if votes[0][1] + TIMEOUT > time(): return votes # no votes have timed out elif len(votes) > 1: return checkTimeOut(votes[1:]) # oldest vote has timed out, continue checking else: return [] # no valid vote left |
sendchannel("Stimme für %s gezählt. Noch %d Stimmen nötig für OP." % (target, difference)) | sendchannel("Stimme für %s gezählt. Noch %d \ Stimmen nötig für OP." % (target, difference)) | def checkTimeOut(votes): if votes[0][1] + TIMEOUT > time(): return votes # no votes have timed out elif len(votes) > 1: return checkTimeOut(votes[1:]) # oldest vote has timed out, continue checking else: return [] # no valid vote left |
sendchannel("Stimme für %s gezählt. Zuständige Stellen sind verständigt." % (target)) | sendchannel("Stimme für %s gezählt. \ Zuständige Stellen sind verständigt." % (target)) | def checkTimeOut(votes): if votes[0][1] + TIMEOUT > time(): return votes # no votes have timed out elif len(votes) > 1: return checkTimeOut(votes[1:]) # oldest vote has timed out, continue checking else: return [] # no valid vote left |
sendchannel("Abstimmung für %s anberaumt. Noch %d Stimmmen nötig für OP." % (target, int(round(len(users)*VOTEQUOTA)) - 1)) lovevotes[target] = [(user,time())] | sendchannel("Abstimmung für %s anberaumt. Noch %d \ Stimmen nötig für OP." % \ (target, int(round(len(users) * VOTEQUOTA)) - 1)) lovevotes[target] = [(user, time())] | def checkTimeOut(votes): if votes[0][1] + TIMEOUT > time(): return votes # no votes have timed out elif len(votes) > 1: return checkTimeOut(votes[1:]) # oldest vote has timed out, continue checking else: return [] # no valid vote left |
if len(lovevotes[nickname]) >= int(round(len(users)*VOTEQUOTA)): | if len(lovevotes[nickname]) >= \ int(round(len(users) * VOTEQUOTA)): | def checkTimeOut(votes): if votes[0][1] + TIMEOUT > time(): return votes # no votes have timed out elif len(votes) > 1: return checkTimeOut(votes[1:]) # oldest vote has timed out, continue checking else: return [] # no valid vote left |
extended permissions. Fo | extended permissions. | def put_object(self, parent_object, connection_name, **data): """Writes the given object to the graph, connected to the given parent. |
def put_wall_post(self, message, profile_id="me"): """Writes a wall post to the given profile's wall. We default to writing to the authenticated user's wall if no profile_id is specified. """ graph.put_object(profile_id, "feed", message=message) def put_comment(self, post_id, message): """Writes the given comment on ... | def delete_object(self, id): """Deletes the object with the given ID from the graph.""" self.request(id, post_args={"method": "delete"}) | |
self.throttle = event.newValue.getAddressPanel().getThrottle() | self.addressPanel = event.newValue.getAddressPanel() self.throttle = self.addressPanel.getThrottle() | def propertyChange(self, event): self.speedTimer.stop() if (event.propertyName == "ThrottleFrame") : # Curent throttle frame changed event.oldValue.getAddressPanel().removeAddressListener(self) self.throttle = event.newValue.getAddressPanel().getThrottle() self.speedAction.setThrottle( self.throttle ) event.newValue.g... |
event.newValue.getAddressPanel().addAddressListener(self) | self.addressPanel.addAddressListener(self) | def propertyChange(self, event): self.speedTimer.stop() if (event.propertyName == "ThrottleFrame") : # Curent throttle frame changed event.oldValue.getAddressPanel().removeAddressListener(self) self.throttle = event.newValue.getAddressPanel().getThrottle() self.speedAction.setThrottle( self.throttle ) event.newValue.g... |
self.getContext().getCurentThrottleFrame().getAddressPanel().addAddressListener(self) | self.addressPanel=self.getContext().getCurentThrottleFrame().getAddressPanel(); self.addressPanel.addAddressListener(self) | def init(self): self.getContext().addPropertyChangeListener(self) #ThrottleFrame change self.getContext().getCurentThrottleFrame().getAddressPanel().addAddressListener(self) # change of throttle in curent frame self.throttle = self.getContext().getCurentThrottleFrame().getAddressPanel().getThrottle() # the throttle sel... |
self.getContext().getCurentThrottleFrame().getAddressPanel().removeAddressListener(self) | self.addressPanel.removeAddressListener(self) self.addressPanel = None | def quit(self): self.speedTimer.stop() WiiRemoteJ.stopFind() if ((self.wiiDevice != None) and (self.wiiDevice.isConnected())): self.wiiDevice.removeWiiRemoteListener(self) self.wiiDevice.disconnect() self.wiiDevice = None self.speedAction = None self.speedTimer = None self.throttle = None self.getContext().removeProper... |
turnout = turnouts.getTurnout("IT:xPA:xAPBSC:"+fmtMsg.getSource()) | turnout = turnouts.getTurnout("IT:xAP:xAPBSC:"+fmtMsg.getSource()) | def processTurnout(self, fmtMsg, message) : pair = fmtMsg.getNameValuePair("output.state","Name") if (pair == None) : print "No Name" name = None else : name = pair.getValue() print " Name:", name pair = fmtMsg.getNameValuePair("output.state","Location") if (pair == None) : print "No Location" location = None el... |
print " create turnout IT:xPA:xAPBSC:"+fmtMsg.getSource() turnout = turnouts.provideTurnout("IT:xPA:xAPBSC:"+fmtMsg.getSource()) | print " create turnout IT:xAP:xAPBSC:"+fmtMsg.getSource() turnout = turnouts.provideTurnout("IT:xAP:xAPBSC:"+fmtMsg.getSource()) | def processTurnout(self, fmtMsg, message) : pair = fmtMsg.getNameValuePair("output.state","Name") if (pair == None) : print "No Name" name = None else : name = pair.getValue() print " Name:", name pair = fmtMsg.getNameValuePair("output.state","Location") if (pair == None) : print "No Location" location = None el... |
print " set turnout IT:xPA:xAPBSC:"+fmtMsg.getSource()+" to", value | print " set turnout IT:xAP:xAPBSC:"+fmtMsg.getSource()+" to", value | def processTurnout(self, fmtMsg, message) : pair = fmtMsg.getNameValuePair("output.state","Name") if (pair == None) : print "No Name" name = None else : name = pair.getValue() print " Name:", name pair = fmtMsg.getNameValuePair("output.state","Location") if (pair == None) : print "No Location" location = None el... |
sensor = sensors.getSensor("IS:xPA:xAPBSC:"+fmtMsg.getSource()) | sensor = sensors.getSensor("IS:xAP:xAPBSC:"+fmtMsg.getSource()) | def processSensor(self, fmtMsg, message) : pair = fmtMsg.getNameValuePair("input.state","Name") if (pair == None) : print "no Name" return name = pair.getValue() print " Name:", name pair = fmtMsg.getNameValuePair("input.state","Location") if (pair == None) : print "no Location" return location = pair.getValue()... |
print " create sensor IS:xPA:xAPBSC:"+fmtMsg.getSource() sensor = sensors.provideSensor("IS:xPA:xAPBSC:"+fmtMsg.getSource()) | print " create sensor IS:xAP:xAPBSC:"+fmtMsg.getSource() sensor = sensors.provideSensor("IS:xAP:xAPBSC:"+fmtMsg.getSource()) | def processSensor(self, fmtMsg, message) : pair = fmtMsg.getNameValuePair("input.state","Name") if (pair == None) : print "no Name" return name = pair.getValue() print " Name:", name pair = fmtMsg.getNameValuePair("input.state","Location") if (pair == None) : print "no Location" return location = pair.getValue()... |
print " set sensor IS:xPA:xAPBSC:"+fmtMsg.getSource()+" to ", value | print " set sensor IS:xAP:xAPBSC:"+fmtMsg.getSource()+" to ", value | def processSensor(self, fmtMsg, message) : pair = fmtMsg.getNameValuePair("input.state","Name") if (pair == None) : print "no Name" return name = pair.getValue() print " Name:", name pair = fmtMsg.getNameValuePair("input.state","Location") if (pair == None) : print "no Location" return location = pair.getValue()... |
self.signalBeyondText.text = self.cvtAppearanceText(nearSignal) | self.signalBeyondText.text = self.cvtAppearanceText(farSignal) | def didWeMove(self) : #self.msgText("didWeMove start: " + self.giveBlockName(self.currentBlock) + ":" + self.giveBlockName(self.nextBlock) + "\n") if (self.currentThrottle == None) : #self.msgText("didWeMove called while currentThrottle was None\n") return #if (self.currentBlock != None) : #self.msgText("Current block:... |
if (self.debugLevel >= MediumDebug) : self.msgText("looking for signal between " + self.giveBlockName(cBlock) + " and " + self.giveBlockName(nBlock) + "\n") | def findNewSpeed(self, cBlock, nBlock) : if (self.isRunning) : if (cBlock == None) : if (nBlock == None) : self.msgText("Failed to find either blocks\n") self.doHalt() else : self.msgText("Failed to find current block\n") self.doHalt() else : if (nBlock == None) : self.msgText("next block doesn't exist, treating as red... | |
if (self.debugLevel >= MediumDebug) : self.msgText("Found currentSignal: " + self.giveSignalName(s) + " displaying: " + self.cvtAppearanceText(s) + "\n") | def findNewSpeed(self, cBlock, nBlock) : if (self.isRunning) : if (cBlock == None) : if (nBlock == None) : self.msgText("Failed to find either blocks\n") self.doHalt() else : self.msgText("Failed to find current block\n") self.doHalt() else : if (nBlock == None) : self.msgText("next block doesn't exist, treating as red... | |
self.msgText("doSpeedGreenFlash: " + i.toString() + "\n") | if (self.debugLevel >= LowDebug) : self.msgText("doSpeedGreenFlash: " + i.toString() + "\n") | def doSpeedGreenFlash(self): if (self.redDelayTimer != None) : self.redDelayTimer.stop() if (self.currentThrottle != None) : i = int(self.locoSpeedGreenFlash.text) * 0.01 self.currentThrottle.setSpeedSetting(i) self.msgText("doSpeedGreenFlash: " + i.toString() + "\n") self.locoSpeed.text = self.locoSpeedGreenFlash.text... |
self.msgText("doSpeedGreen: " + i.toString() + "\n") | if (self.debugLevel >= LowDebug) : self.msgText("doSpeedGreen: " + i.toString() + "\n") | def doSpeedGreen(self): if (self.redDelayTimer != None) : self.redDelayTimer.stop() if (self.currentThrottle != None) : i = int(self.locoSpeedGreen.text) * 0.01 self.currentThrottle.setSpeedSetting(i) self.msgText("doSpeedGreen: " + i.toString() + "\n") self.locoSpeed.text = self.locoSpeedGreen.text return |
self.msgText("doSpeedYellowFlash: " + i.toString() + "\n") | if (self.debugLevel >= LowDebug) : self.msgText("doSpeedYellowFlash: " + i.toString() + "\n") | def doSpeedYellowFlash(self): if (self.redDelayTimer != None) : self.redDelayTimer.stop() if (self.currentThrottle != None) : i = int(self.locoSpeedYellowFlash.text) * 0.01 self.currentThrottle.setSpeedSetting(i) self.msgText("doSpeedYellowFlash: " + i.toString() + "\n") self.locoSpeed.text = self.locoSpeedYellowFlash.... |
self.msgText("doSpeedYellow: " + i.toString() + "\n") | if (self.debugLevel >= LowDebug) : self.msgText("doSpeedYellow: " + i.toString() + "\n") | def doSpeedYellow(self): if (self.redDelayTimer != None) : self.redDelayTimer.stop() if (self.currentThrottle != None) : i = int(self.locoSpeedYellow.text) * 0.01 self.currentThrottle.setSpeedSetting(i) self.msgText("doSpeedYellow: " + i.toString() + "\n") self.locoSpeed.text = self.locoSpeedYellow.text return |
self.msgText("doSpeedRedFlash: " + i.toString() + "\n") | if (self.debugLevel >= LowDebug) : self.msgText("doSpeedRedFlash: " + i.toString() + "\n") | def doSpeedRedFlash(self): if (self.redDelayTimer != None) : self.redDelayTimer.stop() if (self.currentThrottle != None) : i = int(self.locoSpeedRedFlash.text) * 0.01 self.currentThrottle.setSpeedSetting(i) self.msgText("doSpeedRedFlash: " + i.toString() + "\n") self.locoSpeed.text = self.locoSpeedRedFlash.text return |
self.msgText("doSpeedRed: " + i.toString() + "\n") | if (self.debugLevel >= LowDebug) : self.msgText("doSpeedRed: " + i.toString() + "\n") | def doSpeedRed(self): if (self.currentThrottle != None and self.currentThrottle.getSpeedSetting() != 0 and (self.redDelayTimer == None or self.redDelayTimer.isRunning() == False)) : i = int(self.locoSpeedRed.text) * 0.01 self.currentThrottle.setSpeedSetting(i) self.msgText("doSpeedRed: " + i.toString() + "\n") self.loc... |
self.msgText("redDelayHandler, stopping now!\n") | if (self.debugLevel >= LowDebug) : self.msgText("redDelayHandler, stopping now!\n") | def redDelayHandler(self, event) : self.msgText("redDelayHandler, stopping now!\n") self.redDelayTimer.stop() self.doStop() return |
self.msgText("doStop\n") | if (self.debugLevel >= LowDebug) : self.msgText("doStop\n") | def doStop(self): if (self.redDelayTimer != None) : self.redDelayTimer.stop() if (self.currentThrottle != None) : self.currentThrottle.setSpeedSetting(0) self.msgText("doStop\n") self.locoSpeed.text = "0" if (self.currentBlock != None) : self.blockStart.text = self.giveBlockName(self.currentBlock) if (self.stopBlock !=... |
self.msgText("Shrink Display!\n") | if (self.debugLevel >= HighDebug) : self.msgText("Shrink Display!\n") | def whenShrinkButtonClicked(self, event): if (self.shrinkGrow == True) : self.msgText("Shrink Display!\n") # add text self.speedPane.setVisible(False) self.shrinkGrow = False self.fullScrollRows = self.scrollArea.getRows() self.scrollArea.setRows(self.fullScrollRows / 2) self.scriptFrame.pack() else : self.msgText(... |
self.msgText("Grow Display!\n") | if (self.debugLevel >= HighDebug) : self.msgText("Grow Display!\n") | def whenShrinkButtonClicked(self, event): if (self.shrinkGrow == True) : self.msgText("Shrink Display!\n") # add text self.speedPane.setVisible(False) self.shrinkGrow = False self.fullScrollRows = self.scrollArea.getRows() self.scrollArea.setRows(self.fullScrollRows / 2) self.scriptFrame.pack() else : self.msgText(... |
if (self.debugLevel >= HighDebug) : self.msgText("searching " + len(pathList).toString() + " paths from " + self.giveBlockName(cB) + "\n") | def findNextBlock(self, cB) : # look down list of getToBlockDirection for match # use 'suggestion' flag if current block doesn't have direction nB = None dirFlag = cB.getDirection() if (dirFlag == jmri.Path.NONE) : if (self.blockDirection.isSelected() == True) : dirFlag = dirFlag or jmri.Path.EAST else : dirFlag = dirF... | |
if (self.debugLevel >= HighDebug) : self.msgText("findNextBlock path traversable: " + self.giveBlockName(cB) + " to " + self.giveBlockName(blockTest) + " dirTest: " + jmri.Path.decodeDirection(dirTest) + ":" + dirTest.toString() + " dirFlag: " + jmri.Path.decodeDirection(dirFlag) + ":" + dirFlag.toString() + " result:... | def findNextBlock(self, cB) : # look down list of getToBlockDirection for match # use 'suggestion' flag if current block doesn't have direction nB = None dirFlag = cB.getDirection() if (dirFlag == jmri.Path.NONE) : if (self.blockDirection.isSelected() == True) : dirFlag = dirFlag or jmri.Path.EAST else : dirFlag = dirF... | |
self.msgText("findNextBlock Found " + self.giveBlockName(blockTest) + "\n") | if (self.debugLevel >= LowDebug) : self.msgText("findNextBlock Found " + self.giveBlockName(blockTest) + "\n") | def findNextBlock(self, cB) : # look down list of getToBlockDirection for match # use 'suggestion' flag if current block doesn't have direction nB = None dirFlag = cB.getDirection() if (dirFlag == jmri.Path.NONE) : if (self.blockDirection.isSelected() == True) : dirFlag = dirFlag or jmri.Path.EAST else : dirFlag = dirF... |
else : if (self.debugLevel >= MediumDebug) : self.msgText("findNextBlock path not traversable: " + self.giveBlockName(cB) + " to " + self.giveBlockName(blockTest) + "\n") | def findNextBlock(self, cB) : # look down list of getToBlockDirection for match # use 'suggestion' flag if current block doesn't have direction nB = None dirFlag = cB.getDirection() if (dirFlag == jmri.Path.NONE) : if (self.blockDirection.isSelected() == True) : dirFlag = dirFlag or jmri.Path.EAST else : dirFlag = dirF... | |
self.methodPushTest = Ture | self.methodPushTest = True | def pushTest(self) : self.methodPushTest = Ture return |
** version: 0.3 ** | ** version: this is a development version, ** ** see below for details ** | def checkFile(name, comment): flag = os.path.exists(name) if not flag : print "ERROR: file %s is missing" %(name) print "ERROR: %s" %(comment) exit(2) |
using PTools rev.:%s, from branch: %s, unique id: %s | using PTools revision %s, from branch %s, unique id %s | def checkFile(name, comment): flag = os.path.exists(name) if not flag : print "ERROR: file %s is missing" %(name) print "ERROR: %s" %(comment) exit(2) |
flag = os.path.exists(name) if not flag : print "ERROR: file %s is missing" %(name) print "ERROR: %s" %(comment) exit(2) | flag = os.path.exists(name) if not flag : msg = "ERROR: file %s not found\n" %(name) if comment != "": msg += "ERROR: %s" %(comment) sys.exit(msg) | def checkFile(name, comment): flag = os.path.exists(name) if not flag : print "ERROR: file %s is missing" %(name) print "ERROR: %s" %(comment) exit(2) |
parser = OptionParser() parser.add_option("-s", "--single", action="store_true", dest="single",default=False,help="single minimization mode") | parser = OptionParser(usage="%prog -r receptor_file -l ligand_file [-h] [-s] [-t] [--ref]") parser.add_option("-r", "--receptor", action="store", type="string", dest="receptor_name", help="name of the receptor file") parser.add_option("-l", "--ligand", action="store", type="string", dest="ligand_name", help="name of th... | def checkFile(name, comment): flag = os.path.exists(name) if not flag : print "ERROR: file %s is missing" %(name) print "ERROR: %s" %(comment) exit(2) |
receptor_name=args[0] ligand_name=args[1] | def checkFile(name, comment): flag = os.path.exists(name) if not flag : print "ERROR: file %s is missing" %(name) print "ERROR: %s" %(comment) exit(2) | |
** version: this is a development version, ** ** see below for details ** | ** based on the PTools library ** ** ** | def checkFile(name, comment): flag = os.path.exists(name) if not flag : print "ERROR: file %s is missing" %(name) print "ERROR: %s" %(comment) exit(2) |
Attract.py using PTools revision %s, from branch %s, unique id %s | PTools revision %s from branch %s unique id %s | def checkFile(name, comment): flag = os.path.exists(name) if not flag : print "ERROR: file %s is missing" %(name) print "ERROR: %s" %(comment) exit(2) |
import datetime | def checkFile(name, comment): flag = os.path.exists(name) if not flag : print "ERROR: file %s is missing" %(name) print "ERROR: %s" %(comment) exit(2) | |
now = datetime.datetime.now() print now,"(",now.strftime("%A %B %d %Y, %H:%M"),")" | time_start = datetime.datetime.now() print "Start time:", time_start | def checkFile(name, comment): flag = os.path.exists(name) if not flag : print "ERROR: file %s is missing" %(name) print "ERROR: %s" %(comment) exit(2) |
checkFile(receptor_name, "A receptor file is needed.") | if not options.receptor_name: parser.print_help() parser.error("option -r is mandatory") checkFile(options.receptor_name, "") | def checkFile(name, comment): flag = os.path.exists(name) if not flag : print "ERROR: file %s is missing" %(name) print "ERROR: %s" %(comment) exit(2) |
checkFile(ligand_name, "A ligand file is needed.") | if not options.ligand_name: parser.print_help() parser.error("option -l is mandatory") checkFile(options.ligand_name, "") | def checkFile(name, comment): flag = os.path.exists(name) if not flag : print "ERROR: file %s is missing" %(name) print "ERROR: %s" %(comment) exit(2) |
checkFile("attract.inp", "A parameters file is needed.") | checkFile("attract.inp", "parameters file is required.") | def checkFile(name, comment): flag = os.path.exists(name) if not flag : print "ERROR: file %s is missing" %(name) print "ERROR: %s" %(comment) exit(2) |
checkFile("aminon.par", "A forcefield file is needed.") | checkFile("aminon.par", "forcefield file is required.") | def checkFile(name, comment): flag = os.path.exists(name) if not flag : print "ERROR: file %s is missing" %(name) print "ERROR: %s" %(comment) exit(2) |
rec=Rigidbody(receptor_name) lig=Rigidbody(ligand_name) | rec=Rigidbody(options.receptor_name) lig=Rigidbody(options.ligand_name) | def checkFile(name, comment): flag = os.path.exists(name) if not flag : print "ERROR: file %s is missing" %(name) print "ERROR: %s" %(comment) exit(2) |
print "Receptor (fixed) %s has %d particules" %(receptor_name,rec.Size()) print "Ligand (mobile) %s has %d particules" %(ligand_name,lig.Size()) | print "Reading receptor (fixed): %s with %d particules" %( options.receptor_name, rec.Size() ) print "Reading ligand (mobile): %s with %d particules" %( options.ligand_name, lig.Size() ) | def checkFile(name, comment): flag = os.path.exists(name) if not flag : print "ERROR: file %s is missing" %(name) print "ERROR: %s" %(comment) exit(2) |
print "using reference file: %s"%options.reffile | checkFile(options.reffile, "") | def checkFile(name, comment): flag = os.path.exists(name) if not flag : print "ERROR: file %s is missing" %(name) print "ERROR: %s" %(comment) exit(2) |
print "No Calpha atom found for ligand (dna ?), I will calculate rmsd on all grains" | print "No Calpha atom found for ligand (DNA?). RMSD will be calculated on all grains" | def checkFile(name, comment): flag = os.path.exists(name) if not flag : print "ERROR: file %s is missing" %(name) print "ERROR: %s" %(comment) exit(2) |
checkFile("rotation.dat", "A rotation file is needed.") checkFile("translation.dat", "A translation file is needed.\nFormer users may rename translat.dat into translation.dat.") | checkFile("rotation.dat", "rotation file is required.") checkFile("translation.dat", "translation file is required.\nFormer users can rename translat.dat into translation.dat.") | def checkFile(name, comment): flag = os.path.exists(name) if not flag : print "ERROR: file %s is missing" %(name) print "ERROR: %s" %(comment) exit(2) |
print "Single mode" | print "Single mode simulation" | def checkFile(name, comment): flag = os.path.exists(name) if not flag : print "ERROR: file %s is missing" %(name) print "ERROR: %s" %(comment) exit(2) |
checkFile("rotation.dat", "A rotation file is needed.") checkFile("translation.dat", "A translation file is needed.\nFormer users may rename translat.dat into translation.dat.") | checkFile("rotation.dat", "rotation file is required.") checkFile("translation.dat", "translation file is required.\nFormer users may rename translat.dat into translation.dat.") | def checkFile(name, comment): flag = os.path.exists(name) if not flag : print "ERROR: file %s is missing" %(name) print "ERROR: %s" %(comment) exit(2) |
print compress_file(receptor_name) print compress_file(ligand_name) | print compress_file(options.receptor_name) print compress_file(options.ligand_name) | def checkFile(name, comment): flag = os.path.exists(name) if not flag : print "ERROR: file %s is missing" %(name) print "ERROR: %s" %(comment) exit(2) |
now = datetime.datetime.now() print "Finished at: ",now.strftime("%A %B %d %Y, %H:%M") | time_end = datetime.datetime.now() print "End time:", time_end print "Elapsed time:", time_end - time_start | def checkFile(name, comment): flag = os.path.exists(name) if not flag : print "ERROR: file %s is missing" %(name) print "ERROR: %s" %(comment) exit(2) |
if hasattr(self, invalidateTranslationCache): | if hasattr(self, 'invalidateTranslationCache'): | def invalidateTranslations(self, comment=''): """Marks the translation as outdated.""" translations = self.getNonCanonicalTranslations() for lang in translations.keys(): translation = translations[lang][0] translation.notifyCanonicalUpdate() if comment: cUpdate = TranslationObjectUpdate(self, translation,'invalidate', ... |
self.invalidateTranslationCache() | if hasattr(self, invalidateTranslationCache): self.invalidateTranslationCache() | def invalidateTranslations(self, comment=''): """Marks the translation as outdated.""" translations = self.getNonCanonicalTranslations() for lang in translations.keys(): translation = translations[lang][0] translation.notifyCanonicalUpdate() if comment: cUpdate = TranslationObjectUpdate(self, translation,'invalidate', ... |
Possible viewing environments: 1. user owns the list 2. list was shared with the user, but they do not own 3. was not shared with the user and they do not own it 1: provide full editing capabilities (let users remove indicators and share) 2: user can copy to their iLists, or print/download 3: forbidden | def indicator_list(request, indicator_list_slug): """ The public landing page for an Indicator List. Can be used for sharing iLists Possible viewing environments: 1. user owns the list 2. list was shared with the user, but they do not own 3. was not shared with the user and they do not own it 1: provide full editing... | |
IndicatorData.objects.all().delete() | def new_run_all(self, indicator_list=None): from django.db.utils import IntegrityError IndicatorData.objects.all().delete() seen_indicators = set() # to track which Indicators may be gone now created_indicators = set() import copy metadata_to_import = [ metadata for metadata in self.get_metadata() \ if (metadata['indi... | |
if (metadata['indicator_group'] != '' and metadata['display_name'] != '' | if metadata['indicator_group'] != '' and metadata['display_name'] != '' \ | def new_run_all(self, indicator_list=None): from django.db.utils import IntegrityError IndicatorData.objects.all().delete() seen_indicators = set() # to track which Indicators may be gone now created_indicators = set() import copy metadata_to_import = [ metadata for metadata in self.get_metadata() \ if (metadata['indi... |
for metadata in [metadata for metadata in self.get_metadata() if metadata['indicator_group'] != '' and metadata['display_name'] != '']: | print metadata_to_import for metadata in metadata_to_import: | def new_run_all(self, indicator_list=None): from django.db.utils import IntegrityError IndicatorData.objects.all().delete() seen_indicators = set() # to track which Indicators may be gone now created_indicators = set() import copy metadata_to_import = [ metadata for metadata in self.get_metadata() \ if (metadata['indi... |
IndicatorData.objects.filter(indicator=indicator).delete() | indicator_def = self.prep_indicator_definition(metadata) | |
for indicator in Indicator.objects.all(): | if indicator_list: all_indicators = Indicator.objects.filter(name__in=indicator_list) else: all_indicators = Indicator.objects.all() for indicator in all_indicators: | indicator_def = self.prep_indicator_definition(metadata) |
IndicatorData.objects.filter(indicator__=indicator_list).delete() | IndicatorData.objects.filter(indicator__in=indicator_list).delete() | def _run_all(self, indicator_list=None, ignore_celery=False): from django.db.utils import IntegrityError import copy if not indicator_list: indicator_list = Indicator.objects.all() |
'suppresion_threshold', | 'suppression_numerator', 'suppression_denominator', | def unpublish(modeladmin, request, queryset): queryset.update(published=False) |
print data_type | def insert_pregen_data(self, indicator): """ Find all rows for the indicator, and insert each """ count = 0 for pregen_part in indicator.indicatorpregenpart_set.all(): file_path = self.find_file(pregen_part) if not file_path: print "WARNING: Couldn't find a file for %s (searched for %s)" % ( indicator.name, pregen_part... | |
default_list_name = "%s's Indicators" % user.username | default_list_name = "%s's Indicators" % user.email | def get_or_create_default_for_user(self, user): default_list_name = "%s's Indicators" % user.username list, created = self.get_or_create(owner=user, name=default_list_name) user.get_profile().indicator_lists.add(list) return list, created |
def test_celery_performance(indicator_def): """ Run an indicator three ways: 1. By itself, without celery 2. By itself, through celery 3. By itself 4 times Calculate the slowdown incurred by each method, with """ import datetime from indicators.tasks import create_indicator_data i = indicator_def() start1 = datetime... | i_def = IndicatorDef() | |
if indicator not in seend_indicators: | if indicator not in seen_indicators: | indicator_def = self.prep_indicator_definition(metadata) |
indicator_data = self.new_generate_indicator_data( | indicator_data = new_generate_indicator_data( | indicator_def = get_dynamic_indicator_def(metadata) |
time.sleep(10) | indicator_def = get_dynamic_indicator_def(metadata) | |
if metadata['data_type'].lower() == 'numeric': | resolved_type = None if metadata['data_type'].lower() == 'text': resolved_type = 'text' elif metadata['data_type'].lower() == 'numeric': resolved_type = 'numeric' else: try: float(value) resolved_type = 'numeric' except ValueError: resolved_type = 'text' indicator_data_kwargs['data_type'] = resolved_type if indicator_... | def generate_indicator_data(self, metadata, row): from webportal.indicators.models import IndicatorData import datahub.indicators.conversion as conversion value = row[metadata['element_name']] key_field = self.get_key_field(metadata['file_name']) indicator_data_kwargs = { 'data_type': metadata['data_type'].lower() } v... |
else: indicator_data_kwargs['string'] = value | def generate_indicator_data(self, metadata, row): from webportal.indicators.models import IndicatorData import datahub.indicators.conversion as conversion value = row[metadata['element_name']] key_field = self.get_key_field(metadata['file_name']) indicator_data_kwargs = { 'data_type': metadata['data_type'].lower() } v... | |
if file.lower() == metadata['file_name'].lower(): | if file.lower() == metadata['file_name'].lower() or file.lower() == metadata['file_name'].lower() + '.csv': | def find_file(self, metadata): file_path = None for file, path in self.get_files().iteritems(): if file.lower() == metadata['file_name'].lower(): file_path = path return file_path |
======= import os import csv import sys from datahub.indicators.models import Indicator, IndicatorData from django.utils.functional import memoize from django.db import transaction key_field_cache = {} get_files_cache = {} get_variables_cache = {} def safe_strip(val): if isinstance(val, str): return val.strip() retur... | def run_all(self): print 'start' Indicator.objects.all().delete() excel_info = self.grab_xls_info() output_file = open('errors.txt', 'w') for pair in indicator_list(): try: if pair[0] in excel_info.keys(): excel_related_info = excel_info[pair[0]] i = Indicator(name = pair[0], short_label = excel_related_info[0]) #etc... | |
do_get_variables = memoize(do_get_variables, {}, 0) | do_get_variables = memoize(do_get_variables, get_variables_cache, 0) | def do_get_variables(): book = self.open_xsl() sheet = book.sheet_by_index(0) attr_map = [ 'keep_or_drop', 'display', 'data_type', 'min', 'max', 'name', 'dataset_tag', 'file_name', 'icon', 'source', 'time_group', 'year', 'short_label_prefix', 'short_label', 'hover_label', 'variable_definition', 'case_restrictions', 'ca... |
do_get_files = memoize(do_get_files, {}, 0) | do_get_files = memoize(do_get_files, get_files_cache, 0) | def do_get_files(): files = {} for path, subpaths, subfiles in os.walk(self.directory): for filename in subfiles: files[filename] = os.path.join(path, filename) return files |
files = self.get_files() for filename, path in files.iteritems(): if filename.startswith(table_name) and filename.endswith('csv'): reader = csv.reader(open(path, 'rU')) header = reader.next() return header[0] print "WARNING: Couldn't find a key field for %s" % table_name return '' | def do_get_key_field(table_name): print 'in do_get_key_field for %s' % table_name files = self.get_files() for filename, path in files.iteritems(): if filename.startswith(table_name) and filename.endswith('csv'): reader = csv.reader(open(path, 'rU')) header = reader.next() return header[0] print "WARNING: Couldn't fin... | def get_key_field(self, table_name): files = self.get_files() for filename, path in files.iteritems(): if filename.startswith(table_name) and filename.endswith('csv'): # assuming the first column is the key field reader = csv.reader(open(path, 'rU')) header = reader.next() return header[0] print "WARNING: Couldn't find... |
if 'xor-circ' in src_val: print('src: ' + src_path) print('en: ' + en_src) print('xx: ' + xx_src) | def handle_tag(match): values = {} pieces = ['<img'] for attr_match in img_attr_re.finditer(match.group()): attr = attr_match.group(1) values[attr] = attr_match.group(2) if attr not in ['src', 'width', 'height']: pieces.append(attr_match.group()) if 'src' in values: src_val = values['src'] src_path = os.path.normpath(b... | |
for locale in os.listdir(doc_dir): locale_dir = build_path(temp_dir, 'doc', locale) if os.path.isdir(locale_dir) and locale != 'en': src_map = build_path(temp_dir, 'doc/en/map.jhm') shutil.copy(src_map, locale_dir) | def ignore_hidden(dir, files): ret = [] if ignore is None else ignore(dir, files) ret.extend([f for f in files if f.startswith('.') and f not in ret]) return ret | |
debug=True) | debug=False) | def get(self, bookmarklet, link_key): link = db.get(link_key) if link.bookmarklet == bookmarklet: link.delete() self.redirect(link.url) else: self.redirect('/') |
n.append(['0' if s[(4 * x)] == 0 else '1' for x in range((len(s) / 4))]) | n.append([1 if s[(x*4)]==s[(x*4)+1]==s[(x*4)+2]==s[(x*4)+3] else 0 for x in range(int(len(s)/4))]) | def post(self): delList = [] key = self.request.params.get('k', None) now = time.time() seed = self.request.params.get('seed', int(now / 15)) tile = Tile.get(db.Key.from_path('Tiles', key)) if tile: #if it does exist, turn it into a binary 256x256 matrix n = [] row = 0 for s in png.Reader(bytes=tile.band).asRGBA()[2]: ... |
n = [['1' for i in range(256)] for i in range(256)] tile = Tile(key=db.Key.from_path('Tiles', key)) | n = [[1 for i in range(256)] for i in range(256)] tile = Tile(key=db.Key.from_path('Tile', key)) | def post(self): delList = [] key = self.request.params.get('k', None) now = time.time() seed = self.request.params.get('seed', int(now / 15)) tile = Tile.get(db.Key.from_path('Tiles', key)) if tile: #if it does exist, turn it into a binary 256x256 matrix n = [] row = 0 for s in png.Reader(bytes=tile.band).asRGBA()[2]: ... |
t = TileUpdate.get(db.Key.from_path('TileUpdates', tmpK)) | t = TileUpdate.get(db.Key.from_path('TileUpdate', tmpK)) | def post(self): delList = [] key = self.request.params.get('k', None) now = time.time() seed = self.request.params.get('seed', int(now / 15)) tile = Tile.get(db.Key.from_path('Tiles', key)) if tile: #if it does exist, turn it into a binary 256x256 matrix n = [] row = 0 for s in png.Reader(bytes=tile.band).asRGBA()[2]: ... |
t = Tile.get(db.Key.from_path('Tiles', tmpK)) delList.append(db.Key.from_path('TileUpdates', tmpK)) orow = 0 if qt in [0, 1] else 128 ocol = 0 if qt in [0, 2] else 128 if t: nt = png.Reader(bytes=images.resize(t.band, 128, 128)).asRGBA() | t = Tile.get(db.Key.from_path('Tile', tmpK)) delList.append(db.Key.from_path('TileUpdate', tmpK)) orow = 0 if qt in [0,1] else 128 ocol = 0 if qt in [0,2] else 128 if t: tmpI = images.Image(t.band) tmpI.resize(128,128) nt = png.Reader(bytes=tmpI.execute_transforms(output_encoding=images.PNG)).asRGBA8() | def post(self): delList = [] key = self.request.params.get('k', None) now = time.time() seed = self.request.params.get('seed', int(now / 15)) tile = Tile.get(db.Key.from_path('Tiles', key)) if tile: #if it does exist, turn it into a binary 256x256 matrix n = [] row = 0 for s in png.Reader(bytes=tile.band).asRGBA()[2]: ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.