comparison tincan.py @ 42:8948020c54fd draft

Remove some debug deadwood, ignore hidden files.
author David Barts <n5jrn@me.com>
date Wed, 29 May 2019 16:51:33 -0700
parents 9335865ae0bb
children 0bd9b9ae9998
comparison
equal deleted inserted replaced
41:9335865ae0bb 42:8948020c54fd
428 try: 428 try:
429 with open(self._fspath, "rb") as fp: 429 with open(self._fspath, "rb") as fp:
430 mtime = os.fstat(fp.fileno()).st_mtime 430 mtime = os.fstat(fp.fileno()).st_mtime
431 bytes = fp.read() 431 bytes = fp.read()
432 except FileNotFoundError as e: 432 except FileNotFoundError as e:
433 print(e) # debug
434 return bottle.HTTPError(status=404, exception=e) 433 return bottle.HTTPError(status=404, exception=e)
435 except PermissionError as e: 434 except PermissionError as e:
436 print(e) # debug
437 return bottle.HTTPError(status=403, exception=e) 435 return bottle.HTTPError(status=403, exception=e)
438 except OSError as e: 436 except OSError as e:
439 print(e) # debug
440 return bottle.HTTPError(status=500, exception=e) 437 return bottle.HTTPError(status=500, exception=e)
441 # Establish preliminary standard headers. 438 # Establish preliminary standard headers.
442 headers = { 439 headers = {
443 "Content-Type": self._type, 440 "Content-Type": self._type,
444 "Last-Modified": time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime(mtime)), 441 "Last-Modified": time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime(mtime)),
809 self._launch([]) 806 self._launch([])
810 return self 807 return self
811 808
812 def _launch(self, subdir): 809 def _launch(self, subdir):
813 for entry in os.listdir(os.path.join(self.fsroot, *subdir)): 810 for entry in os.listdir(os.path.join(self.fsroot, *subdir)):
811 if entry.startswith("."):
812 continue # hidden file
814 if not subdir and entry in _BANNED: 813 if not subdir and entry in _BANNED:
815 continue 814 continue
816 etype = os.stat(os.path.join(self.fsroot, *subdir, entry)).st_mode 815 etype = os.stat(os.path.join(self.fsroot, *subdir, entry)).st_mode
817 if S_ISREG(etype): 816 if S_ISREG(etype):
818 ename, eext = os.path.splitext(entry) 817 ename, eext = os.path.splitext(entry)