Python uerrno.ENOENT Examples
The following are 8
code examples of uerrno.ENOENT().
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
uerrno
, or try the search function
.
Example #1
Source File: __init__.py From uPyCam with Apache License 2.0 | 5 votes |
def remove_writer(self, sock): if DEBUG and __debug__: log.debug("remove_writer(%s)", sock) try: self.poller.unregister(sock) self.objmap.pop(id(sock), None) except OSError as e: # StreamWriter.awrite() first tries to write to a socket, # and if that succeeds, yield IOWrite may never be called # for that socket, and it will never be added to poller. So, # ignore such error. if e.args[0] != uerrno.ENOENT: raise
Example #2
Source File: __init__.py From micropython-samples with MIT License | 5 votes |
def remove_writer(self, sock): if DEBUG and __debug__: log.debug("remove_writer(%s)", sock) try: self.poller.unregister(sock) self.objmap.pop(id(sock), None) except OSError as e: # StreamWriter.awrite() first tries to write to a socket, # and if that succeeds, yield IOWrite may never be called # for that socket, and it will never be added to poller. So, # ignore such error. if e.args[0] != uerrno.ENOENT: raise
Example #3
Source File: __init__.py From micropython-samples with MIT License | 5 votes |
def sendfile(self, writer, fname, content_type=None, headers=None): if not content_type: content_type = get_mime_type(fname) try: with pkg_resources.resource_stream(self.pkg, fname) as f: yield from start_response(writer, content_type, "200", headers) yield from sendstream(writer, f) except OSError as e: if e.args[0] == uerrno.ENOENT: yield from http_error(writer, "404") else: raise
Example #4
Source File: __init__.py From microdot with MIT License | 5 votes |
def remove_writer(self, sock): if DEBUG and __debug__: log.debug("remove_writer(%s)", sock) try: self.poller.unregister(sock) self.objmap.pop(id(sock), None) except OSError as e: # StreamWriter.awrite() first tries to write to a socket, # and if that succeeds, yield IOWrite may never be called # for that socket, and it will never be added to poller. So, # ignore such error. if e.args[0] != uerrno.ENOENT: raise
Example #5
Source File: __init__.py From pysmartnode with MIT License | 5 votes |
def remove_writer(self, sock): if DEBUG and __debug__: log.debug("remove_writer(%s)", sock) try: self.poller.unregister(sock) self.objmap.pop(id(sock), None) except OSError as e: # StreamWriter.awrite() first tries to write to a socket, # and if that succeeds, yield IOWrite may never be called # for that socket, and it will never be added to poller. So, # ignore such error. if e.args[0] != uerrno.ENOENT: raise
Example #6
Source File: __init__.py From picoweb with MIT License | 5 votes |
def sendfile(self, writer, fname, content_type=None, headers=None): if not content_type: content_type = get_mime_type(fname) try: with pkg_resources.resource_stream(self.pkg, fname) as f: yield from start_response(writer, content_type, "200", headers) yield from sendstream(writer, f) except OSError as e: if e.args[0] == uerrno.ENOENT: yield from http_error(writer, "404") else: raise
Example #7
Source File: __init__.py From microhomie with MIT License | 5 votes |
def remove_writer(self, sock): if DEBUG and __debug__: log.debug("remove_writer(%s)", sock) try: self.poller.unregister(sock) self.objmap.pop(id(sock), None) except OSError as e: # StreamWriter.awrite() first tries to write to a socket, # and if that succeeds, yield IOWrite may never be called # for that socket, and it will never be added to poller. So, # ignore such error. if e.args[0] != uerrno.ENOENT: raise
Example #8
Source File: server.py From tinyweb with MIT License | 4 votes |
def send_file(self, filename, content_type=None, content_encoding=None, max_age=2592000): """Send local file as HTTP response. This function is generator. Arguments: filename - Name of file which exists in local filesystem Keyword arguments: content_type - Filetype. By default - None means auto-detect. max_age - Cache control. How long browser can keep this file on disk. By default - 30 days Set to 0 - to disable caching. Example 1: Default use case: await resp.send_file('images/cat.jpg') Example 2: Disable caching: await resp.send_file('static/index.html', max_age=0) Example 3: Override content type: await resp.send_file('static/file.bin', content_type='application/octet-stream') """ try: # Get file size stat = os.stat(filename) slen = str(stat[6]) self.add_header('Content-Length', slen) # Find content type if content_type: self.add_header('Content-Type', content_type) # Add content-encoding, if any if content_encoding: self.add_header('Content-Encoding', content_encoding) # Since this is static content is totally make sense # to tell browser to cache it, however, you can always # override it by setting max_age to zero self.add_header('Cache-Control', 'max-age={}, public'.format(max_age)) with open(filename) as f: await self._send_headers() gc.collect() buf = bytearray(128) while True: size = f.readinto(buf) if size == 0: break await self.send(buf, sz=size) except OSError as e: # special handling for ENOENT / EACCESS if e.args[0] in (errno.ENOENT, errno.EACCES): raise HTTPException(404) else: raise