Python twisted.python.log.err() Examples
The following are 30
code examples of twisted.python.log.err().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
twisted.python.log
, or try the search function
.
Example #1
Source File: service.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 6 votes |
def _setTopic(self, channel, topic): #<< TOPIC #divunal :foo #>> :glyph!glyph@adsl-64-123-27-108.dsl.austtx.swbell.net TOPIC #divunal :foo def cbGroup(group): newMeta = group.meta.copy() newMeta['topic'] = topic newMeta['topic_author'] = self.name newMeta['topic_date'] = int(time()) def ebSet(err): self.sendMessage( irc.ERR_CHANOPRIVSNEEDED, "#" + group.name, ":You need to be a channel operator to do that.") return group.setMetadata(newMeta).addErrback(ebSet) def ebGroup(err): err.trap(ewords.NoSuchGroup) self.sendMessage( irc.ERR_NOSUCHCHANNEL, '=', channel, ":That channel doesn't exist.") self.realm.lookupGroup(channel).addCallbacks(cbGroup, ebGroup)
Example #2
Source File: palmacqprotocol.py From magpy with BSD 3-Clause "New" or "Revised" License | 6 votes |
def dataToFile(outputdir, sensorid, filedate, bindata, header): # File Operations try: hostname = socket.gethostname() path = os.path.join(outputdir,hostname,sensorid) # outputdir defined in main options class if not os.path.exists(path): os.makedirs(path) savefile = os.path.join(path, sensorid+'_'+filedate+".bin") if not os.path.isfile(savefile): with open(savefile, "wb") as myfile: myfile.write(header + "\n") myfile.write(bindata + "\n") else: with open(savefile, "a") as myfile: myfile.write(bindata + "\n") except: log.err("PalmAcq - Protocol: Error while saving file") ## PalmAcq protocol ## --------------------
Example #3
Source File: bm35protocol.py From magpy with BSD 3-Clause "New" or "Revised" License | 6 votes |
def dataToFile(outputdir, sensorid, filedate, bindata, header): # File Operations try: hostname = socket.gethostname() path = os.path.join(outputdir,hostname,sensorid) # outputdir defined in main options class if not os.path.exists(path): os.makedirs(path) savefile = os.path.join(path, sensorid+'_'+filedate+".bin") if not os.path.isfile(savefile): with open(savefile, "wb") as myfile: myfile.write(header + "\n") myfile.write(bindata + "\n") else: with open(savefile, "a") as myfile: myfile.write(bindata + "\n") except: log.err("Protocol: Error while saving file") ## meteolabor BM35 protocol ##
Example #4
Source File: utility.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 6 votes |
def callback(self, *args, **kwargs): """ Call all registered callbacks. The passed arguments are event specific and augment and override the callback specific arguments as described above. @note: Exceptions raised by callbacks are trapped and logged. They will not propagate up to make sure other callbacks will still be called, and the event dispatching always succeeds. @param args: Positional arguments to the callable. @type args: C{list} @param kwargs: Keyword arguments to the callable. @type kwargs: C{dict} """ for key, (methodwrapper, onetime) in list(self.callbacks.items()): try: methodwrapper(*args, **kwargs) except: log.err() if onetime: del self.callbacks[key]
Example #5
Source File: callprotocol.py From magpy with BSD 3-Clause "New" or "Revised" License | 6 votes |
def dataToCSV(self, sensorid, filedate, asciidata, header): # File Operations #try: path = os.path.join(self.outputdir,self.hostname,sensorid) if not os.path.exists(path): os.makedirs(path) savefile = os.path.join(path, sensorid+'_'+filedate+".asc") asciilist = asciidata.split(';') if not os.path.isfile(savefile): with open(savefile, "wb") as csvfile: writer = csv.writer(csvfile,delimiter=';') writer.writerow(header) writer.writerow(asciilist) else: with open(savefile, "a") as csvfile: writer = csv.writer(csvfile,delimiter=';') writer.writerow(asciilist) #except: #log.err("datatoCSV: Error while saving file")
Example #6
Source File: kernprotocol.py From magpy with BSD 3-Clause "New" or "Revised" License | 6 votes |
def dataToFile(outputdir, sensorid, filedate, bindata, header): # File Operations try: hostname = socket.gethostname() path = os.path.join(outputdir,hostname,sensorid) # outputdir defined in main options class if not os.path.exists(path): os.makedirs(path) savefile = os.path.join(path, sensorid+'_'+filedate+".bin") if not os.path.isfile(savefile): with open(savefile, "wb") as myfile: myfile.write(header + "\n") myfile.write(bindata + "\n") else: with open(savefile, "a") as myfile: myfile.write(bindata + "\n") except: log.err("KERN - Protocol: Error while saving file") ## Environment protocol ## --------------------
Example #7
Source File: http.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 6 votes |
def _authorize(self): # Authorization, (mostly) per the RFC try: authh = self.getHeader(b"Authorization") if not authh: self.user = self.password = '' return bas, upw = authh.split() if bas.lower() != b"basic": raise ValueError() upw = base64.decodestring(upw) self.user, self.password = upw.split(b':', 1) except (binascii.Error, ValueError): self.user = self.password = "" except: log.err() self.user = self.password = ""
Example #8
Source File: llvmpoller.py From llvm-zorg with Apache License 2.0 | 6 votes |
def poll(self): # Return value is only used for unit testing. if self.projects: log.msg("LLVMPoller(%s): Polling %s projects" % (self.svnurl, self.projects)) else: log.msg("LLVMPoller(%s): Polling all projects" % self.svnurl) d = defer.succeed(None) d.addCallback(self.get_logs) d.addCallback(self.parse_logs) d.addCallback(self.get_new_logentries) d.addCallback(self.create_changes) d.addCallback(self.submit_changes) d.addCallback(self.finished_ok) d.addErrback(log.err, 'LLVMPoller: Error in while polling') # eat errors return d
Example #9
Source File: client.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 6 votes |
def _handleRedirect(self, response, method, uri, headers, redirectCount): """ Handle a redirect response, checking the number of redirects already followed, and extracting the location header fields. """ if redirectCount >= self._redirectLimit: err = error.InfiniteRedirection( response.code, b'Infinite redirection detected', location=uri) raise ResponseFailed([Failure(err)], response) locationHeaders = response.headers.getRawHeaders(b'location', []) if not locationHeaders: err = error.RedirectWithNoLocation( response.code, b'No location header field', uri) raise ResponseFailed([Failure(err)], response) location = self._resolveLocation(uri, locationHeaders[0]) deferred = self._agent.request(method, location, headers) def _chainResponse(newResponse): newResponse.setPreviousResponse(response) return newResponse deferred.addCallback(_chainResponse) return deferred.addCallback( self._handleResponse, method, uri, headers, redirectCount + 1)
Example #10
Source File: llvmgitpoller.py From llvm-zorg with Apache License 2.0 | 6 votes |
def startService(self): # make our workdir absolute, relative to the master's basedir if not os.path.isabs(self.workdir): self.workdir = os.path.join(self.master.basedir, self.workdir) log.msg("LLVMGitPoller: using workdir '%s'" % self.workdir) # initialize the repository we'll use to get changes; note that # startService is not an event-driven method, so this method will # instead acquire self.initLock immediately when it is called. if not os.path.exists(self.workdir + r'/.git'): d = self.initRepository() d.addErrback(log.err, 'while initializing LLVMGitPoller repository') else: log.msg("LLVMGitPoller repository already exists") # call this *after* initRepository, so that the initLock is locked first base.PollingChangeSource.startService(self)
Example #11
Source File: github.py From llvm-zorg with Apache License 2.0 | 6 votes |
def _sendGitHubStatus(self, status): """ Send status to GitHub API. """ d = self._github.repos.createStatus( repo_user=status['repoOwner'].encode('utf-8'), repo_name=status['repoName'].encode('utf-8'), sha=status['sha'].encode('utf-8'), state=status['state'].encode('utf-8'), target_url=status['targetURL'].encode('utf-8'), description=status['description'].encode('utf-8'), context=status['builderName'].encode('utf-8'), ) success_message = ( 'GitHubStatus: Status "%(state)s" sent for ' '%(repoOwner)s/%(repoName)s at %(sha)s.' ) % status error_message = ( 'GitHubStatus: Fail to send status "%(state)s" for ' '%(repoOwner)s/%(repoName)s at %(sha)s.' ) % status d.addCallback(lambda result: log.msg(success_message)) d.addErrback(lambda failure: log.err(failure, error_message)) return d
Example #12
Source File: github.py From llvm-zorg with Apache License 2.0 | 6 votes |
def buildFinished(self, builderName, build, results): """ See: C{IStatusReceiver}. """ if self._builders_to_report and (builderName not in self._builders_to_report): # Build finished on a builder we do not care of. return # skip unless white listed # For now we report only properly completed builds without buildbot errors. if results != SUCCESS and results != FAILURE: return # skip error builds d = self._sendFinishStatus(builderName, build, results) d.addErrback(log.err, 'GitHubStatus: While sending finish status to GitHub for %s.' % (builderName,))
Example #13
Source File: arduinoprotocol.py From magpy with BSD 3-Clause "New" or "Revised" License | 6 votes |
def dataToFile(outputdir, sensorid, filedate, bindata, header): # File Operations try: hostname = socket.gethostname() path = os.path.join(outputdir,hostname,sensorid) # outputdir defined in main options class if not os.path.exists(path): os.makedirs(path) savefile = os.path.join(path, sensorid+'_'+filedate+".bin") if not os.path.isfile(savefile): with open(savefile, "wb") as myfile: myfile.write(header + "\n") myfile.write(bindata + "\n") else: with open(savefile, "a") as myfile: myfile.write(bindata + "\n") except: log.err("Arduino - Protocol: Error while saving file") ## Arduino protocol ## --------------------
Example #14
Source File: envprotocol.py From magpy with BSD 3-Clause "New" or "Revised" License | 6 votes |
def dataToFile(outputdir, sensorid, filedate, bindata, header): # File Operations try: hostname = socket.gethostname() path = os.path.join(outputdir,hostname,sensorid) # outputdir defined in main options class if not os.path.exists(path): os.makedirs(path) savefile = os.path.join(path, sensorid+'_'+filedate+".bin") if not os.path.isfile(savefile): with open(savefile, "wb") as myfile: myfile.write(header + "\n") myfile.write(bindata + "\n") else: with open(savefile, "a") as myfile: myfile.write(bindata + "\n") except: log.err("OW - Protocol: Error while saving file") ## Environment protocol ## --------------------
Example #15
Source File: wrapper.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 6 votes |
def _authorizedResource(self, request): """ Get the L{IResource} which the given request is authorized to receive. If the proper authorization headers are present, the resource will be requested from the portal. If not, an anonymous login attempt will be made. """ authheader = request.getHeader(b'authorization') if not authheader: return util.DeferredResource(self._login(Anonymous())) factory, respString = self._selectParseHeader(authheader) if factory is None: return UnauthorizedResource(self._credentialFactories) try: credentials = factory.decode(respString, request) except error.LoginFailed: return UnauthorizedResource(self._credentialFactories) except: log.err(None, "Unexpected failure from credentials factory") return ErrorPage(500, None, None) else: return util.DeferredResource(self._login(credentials))
Example #16
Source File: _newclient.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 6 votes |
def _writeToBodyProducerChunked(self, transport): """ Write this request to the given transport using chunked transfer-encoding to frame the body. @param transport: See L{writeTo}. @return: See L{writeTo}. """ self._writeHeaders(transport, b'Transfer-Encoding: chunked\r\n') encoder = ChunkedEncoder(transport) encoder.registerProducer(self.bodyProducer, True) d = self.bodyProducer.startProducing(encoder) def cbProduced(ignored): encoder.unregisterProducer() def ebProduced(err): encoder._allowNoMoreWrites() # Don't call the encoder's unregisterProducer because it will write # a zero-length chunk. This would indicate to the server that the # request body is complete. There was an error, though, so we # don't want to do that. transport.unregisterProducer() return err d.addCallbacks(cbProduced, ebProduced) return d
Example #17
Source File: cobs_ws_protocols.py From magpy with BSD 3-Clause "New" or "Revised" License | 6 votes |
def dataToFile(sensorid, filedate, bindata, header): # File Operations try: subdirname = socket.gethostname() path = os.path.join(outputdir,subdirname,sensorid) # outputdir defined in main options class if not os.path.exists(path): os.makedirs(path) savefile = os.path.join(path, sensorid+'_'+filedate+".bin") if not os.path.isfile(savefile): with open(savefile, "wb") as myfile: myfile.write(header + "\n") myfile.write(bindata + "\n") else: with open(savefile, "a") as myfile: myfile.write(bindata + "\n") except: log.err("OW - Protocol: Error while saving file")
Example #18
Source File: server.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 6 votes |
def processingFailed(self, reason): log.err(reason) if self.site.displayTracebacks: body = (b"<html><head><title>web.Server Traceback" b" (most recent call last)</title></head>" b"<body><b>web.Server Traceback" b" (most recent call last):</b>\n\n" + util.formatFailure(reason) + b"\n\n</body></html>\n") else: body = (b"<html><head><title>Processing Failed" b"</title></head><body>" b"<b>Processing Failed</b></body></html>") self.setResponseCode(http.INTERNAL_SERVER_ERROR) self.setHeader(b'content-type', b"text/html") self.setHeader(b'content-length', intToBytes(len(body))) self.write(body) self.finish() return reason
Example #19
Source File: cobs_ws_protocols.py From magpy with BSD 3-Clause "New" or "Revised" License | 6 votes |
def lineReceived(self, line): dispatch_url = "http://example.com/"+hostname+"/cs#"+self.sensor+"-value" try: data = line.strip('$').split(',') evt1, evt4 = self.processData(data) except ValueError: log.err('CS - Protocol: Unable to parse data %s' % line) #return except: pass if evt1['value'] and evt4['value']: try: ## publish event to all clients subscribed to topic ## self.wsMcuFactory.dispatch(dispatch_url, evt1) self.wsMcuFactory.dispatch(dispatch_url, evt4) #log.msg("Analog value: %s" % str(evt4)) except: log.err('CS - Protocol: wsMcuFactory error while dispatching data.')
Example #20
Source File: csprotocol.py From magpy with BSD 3-Clause "New" or "Revised" License | 6 votes |
def dataToFile(outputdir, sensorid, filedate, bindata, header): # File Operations try: hostname = socket.gethostname() path = os.path.join(outputdir,hostname,sensorid) # outputdir defined in main options class if not os.path.exists(path): os.makedirs(path) savefile = os.path.join(path, sensorid+'_'+filedate+".bin") if not os.path.isfile(savefile): with open(savefile, "wb") as myfile: myfile.write(header + "\n") myfile.write(bindata + "\n") else: with open(savefile, "a") as myfile: myfile.write(bindata + "\n") except: log.err("OW - Protocol: Error while saving file") ## Caesium protocol ##
Example #21
Source File: gsm90protocol.py From magpy with BSD 3-Clause "New" or "Revised" License | 6 votes |
def dataToFile(outputdir, sensorid, filedate, bindata, header): # File Operations try: hostname = socket.gethostname() path = os.path.join(outputdir,hostname,sensorid) # outputdir defined in main options class if not os.path.exists(path): os.makedirs(path) savefile = os.path.join(path, sensorid+'_'+filedate+".bin") if not os.path.isfile(savefile): with open(savefile, "wb") as myfile: myfile.write(header + "\n") myfile.write(bindata + "\n") else: with open(savefile, "a") as myfile: myfile.write(bindata + "\n") except: log.err("OW - Protocol: Error while saving file") ## GEM -GSM90 protocol ##
Example #22
Source File: gsm90protocol.py From magpy with BSD 3-Clause "New" or "Revised" License | 6 votes |
def lineReceived(self, line): dispatch_url = "http://example.com/"+self.hostname+"/gsm#"+self.sensor+"-value" try: data = line #print ("Line", line) evt1, evt3, evt10, evt99 = self.processData(data) except ValueError: log.err('GSM90 - Protocol: Unable to parse data %s' % line) except: pass try: ## publish event to all clients subscribed to topic ## self.wsMcuFactory.dispatch(dispatch_url, evt1) self.wsMcuFactory.dispatch(dispatch_url, evt3) self.wsMcuFactory.dispatch(dispatch_url, evt10) self.wsMcuFactory.dispatch(dispatch_url, evt99) except: log.err('GSM90 - Protocol: wsMcuFactory error while dispatching data.')
Example #23
Source File: gsm19protocol.py From magpy with BSD 3-Clause "New" or "Revised" License | 6 votes |
def dataToFile(outputdir, sensorid, filedate, bindata, header): # File Operations try: hostname = socket.gethostname() path = os.path.join(outputdir,hostname,sensorid) # outputdir defined in main options class if not os.path.exists(path): os.makedirs(path) savefile = os.path.join(path, sensorid+'_'+filedate+".bin") if not os.path.isfile(savefile): with open(savefile, "wb") as myfile: myfile.write(header + "\n") myfile.write(bindata + "\n") else: with open(savefile, "a") as myfile: myfile.write(bindata + "\n") except: log.err("Protocol: Error while saving file") ## GEM -GSM19 protocol ##
Example #24
Source File: gsm19protocol.py From magpy with BSD 3-Clause "New" or "Revised" License | 6 votes |
def lineReceived(self, line): dispatch_url = "http://example.com/"+self.hostname+"/gn#"+self.sensor+"-value" #print ("got", line) try: #print line evt1, evt3, evt10, evt99 = self.processData(line) except ValueError: log.err('GSM19 - Protocol: Unable to parse data %s' % line) except: pass #print "Evt:", evt10, evt1 try: ## publish event to all clients subscribed to topic ## self.wsMcuFactory.dispatch(dispatch_url, evt1) self.wsMcuFactory.dispatch(dispatch_url, evt3) self.wsMcuFactory.dispatch(dispatch_url, evt10) self.wsMcuFactory.dispatch(dispatch_url, evt99) except: log.err('GSM19 - Protocol: wsMcuFactory error while dispatching data.')
Example #25
Source File: pbsupport.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 6 votes |
def logOn(self, chatui): """ @returns: this breaks with L{interfaces.IAccount} @returntype: DeferredList of L{interfaces.IClient}s """ # Overriding basesupport's implementation on account of the # fact that _startLogOn tends to return a deferredList rather # than a simple Deferred, and we need to do registerAccountClient. if (not self._isConnecting) and (not self._isOnline): self._isConnecting = 1 d = self._startLogOn(chatui) d.addErrback(self._loginFailed) def registerMany(results): for success, result in results: if success: chatui.registerAccountClient(result) self._cb_logOn(result) else: log.err(result) d.addCallback(registerMany) return d else: raise error.ConnectionError("Connection in progress")
Example #26
Source File: test_incoming_mail.py From bitmask-dev with GNU General Public License v3.0 | 6 votes |
def testFlagMessageOnBadJsonWhileDecrypting(self): doc = SoledadDocument() doc.doc_id = '1' doc.content = {'_enc_json': ''} err = ValueError('No JSON object could be decoded') def assert_failure(): mock_logger_error.assert_any_call( 'Error while decrypting 1') mock_logger_error.assert_any_call( 'No JSON object could be decoded') self.assertEquals(doc.content['errdecr'], True) with patch.object(Logger, 'error') as mock_logger_error: with patch.object(utils, 'json_loads') as mock_json_loader: self.fetcher._update_incoming_message = Mock() mock_json_loader.side_effect = err self.fetcher._process_decrypted_doc(doc, '') assert_failure()
Example #27
Source File: gsmp20protocol.py From magpy with BSD 3-Clause "New" or "Revised" License | 6 votes |
def dataToFile(outputdir, sensorid, filedate, bindata, header): # File Operations try: hostname = socket.gethostname() path = os.path.join(outputdir,hostname,sensorid) # outputdir defined in main options class if not os.path.exists(path): os.makedirs(path) savefile = os.path.join(path, sensorid+'_'+filedate+".bin") if not os.path.isfile(savefile): with open(savefile, "wb") as myfile: myfile.write(header + "\n") myfile.write(bindata + "\n") else: with open(savefile, "a") as myfile: myfile.write(bindata + "\n") except: log.err("GSMP20 - Protocol: Error while saving file") ## GEM -GSMP-20S3 protocol -- North-South ##
Example #28
Source File: gsmp20protocol.py From magpy with BSD 3-Clause "New" or "Revised" License | 6 votes |
def lineReceived(self, line): dispatch_url = "http://example.com/"+self.hostname+"/sug#"+self.sensor+"-value" try: #print line evt1,evt3,evt20,evt21,evt22,evt23,evt24,evt25,evt99 = self.processData(line) #except ValueError: #log.err('GSMP20 - Protocol: Unable to parse data %s' % line) ## publish event to all clients subscribed to topic ## self.wsMcuFactory.dispatch(dispatch_url, evt1) self.wsMcuFactory.dispatch(dispatch_url, evt3) self.wsMcuFactory.dispatch(dispatch_url, evt20) self.wsMcuFactory.dispatch(dispatch_url, evt21) self.wsMcuFactory.dispatch(dispatch_url, evt22) self.wsMcuFactory.dispatch(dispatch_url, evt23) self.wsMcuFactory.dispatch(dispatch_url, evt24) self.wsMcuFactory.dispatch(dispatch_url, evt25) self.wsMcuFactory.dispatch(dispatch_url, evt99) except: pass
Example #29
Source File: test_incoming_mail.py From bitmask-dev with GNU General Public License v3.0 | 6 votes |
def testExtractInvalidAttachedKey(self): KEY = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n..." message = MIMEMultipart() message.add_header("from", ADDRESS_2) key = MIMEApplication("", "pgp-keys") key.set_payload(KEY) message.attach(key) self.fetcher._keymanager.put_raw_key = Mock( return_value=defer.fail(KeyAddressMismatch())) def put_raw_key_called(_): self.fetcher._keymanager.put_raw_key.assert_called_once_with( KEY, address=ADDRESS_2) d = self._do_fetch(message.as_string()) d.addCallback(put_raw_key_called) d.addErrback(log.err) return d
Example #30
Source File: service.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 6 votes |
def _ebLogin(self, err, nickname): if err.check(ewords.AlreadyLoggedIn): self.privmsg( NICKSERV, nickname, "Already logged in. No pod people allowed!") elif err.check(ecred.UnauthorizedLogin): self.privmsg( NICKSERV, nickname, "Login failed. Goodbye.") else: log.msg("Unhandled error during login:") log.err(err) self.privmsg( NICKSERV, nickname, "Server error during login. Sorry.") self.transport.loseConnection() # Great, now that's out of the way, here's some of the interesting # bits