mirror of
https://github.com/9001/copyparty.git
synced 2025-08-18 09:22:31 -06:00
announce the rotates
This commit is contained in:
parent
4bc39f3084
commit
e59b077c21
|
@ -32,13 +32,15 @@ class SvcHub(object):
|
||||||
def __init__(self, args, argv, printed):
|
def __init__(self, args, argv, printed):
|
||||||
self.args = args
|
self.args = args
|
||||||
self.argv = argv
|
self.argv = argv
|
||||||
|
self.logf = None
|
||||||
|
|
||||||
self.ansi_re = re.compile("\033\\[[^m]*m")
|
self.ansi_re = re.compile("\033\\[[^m]*m")
|
||||||
self.log_mutex = threading.Lock()
|
self.log_mutex = threading.Lock()
|
||||||
self.next_day = 0
|
self.next_day = 0
|
||||||
|
|
||||||
self.log = self._log_disabled if args.q else self._log_enabled
|
self.log = self._log_disabled if args.q else self._log_enabled
|
||||||
self.logf = self._setup_logfile(printed) if args.lo else None
|
if args.lo:
|
||||||
|
self._setup_logfile(printed)
|
||||||
|
|
||||||
# initiate all services to manage
|
# initiate all services to manage
|
||||||
self.asrv = AuthSrv(self.args, self.log, False)
|
self.asrv = AuthSrv(self.args, self.log, False)
|
||||||
|
@ -112,8 +114,11 @@ class SvcHub(object):
|
||||||
else:
|
else:
|
||||||
argv = ['"{}"'.format(x) for x in argv]
|
argv = ['"{}"'.format(x) for x in argv]
|
||||||
|
|
||||||
|
msg = "[+] opened logfile [{}]\n".format(fn)
|
||||||
|
printed += msg
|
||||||
lh.write("t0: {:.3f}\nargv: {}\n\n{}".format(E.t0, " ".join(argv), printed))
|
lh.write("t0: {:.3f}\nargv: {}\n\n{}".format(E.t0, " ".join(argv), printed))
|
||||||
return lh
|
self.logf = lh
|
||||||
|
print(msg, end="")
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
thr = threading.Thread(target=self.tcpsrv.run, name="svchub-main")
|
thr = threading.Thread(target=self.tcpsrv.run, name="svchub-main")
|
||||||
|
@ -164,7 +169,7 @@ class SvcHub(object):
|
||||||
def _set_next_day(self):
|
def _set_next_day(self):
|
||||||
if self.next_day and self.logf and self.logf.base_fn != self._logname():
|
if self.next_day and self.logf and self.logf.base_fn != self._logname():
|
||||||
self.logf.close()
|
self.logf.close()
|
||||||
self.logf = self._setup_logfile("")
|
self._setup_logfile("")
|
||||||
|
|
||||||
dt = datetime.utcfromtimestamp(time.time())
|
dt = datetime.utcfromtimestamp(time.time())
|
||||||
|
|
||||||
|
@ -258,5 +263,5 @@ class SvcHub(object):
|
||||||
if not err:
|
if not err:
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
self.log("root", err)
|
self.log("svchub", err)
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -979,7 +979,7 @@ def statdir(logger, scandir, lstat, top):
|
||||||
try:
|
try:
|
||||||
yield [fsdec(fh.name), fh.stat(follow_symlinks=not lstat)]
|
yield [fsdec(fh.name), fh.stat(follow_symlinks=not lstat)]
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
logger(src, "stat {} @ {}".format(repr(ex), fsdec(fh.path)), 6)
|
logger(src, "[s] {} @ {}".format(repr(ex), fsdec(fh.path)), 6)
|
||||||
else:
|
else:
|
||||||
src = "listdir"
|
src = "listdir"
|
||||||
fun = os.lstat if lstat else os.stat
|
fun = os.lstat if lstat else os.stat
|
||||||
|
@ -988,7 +988,7 @@ def statdir(logger, scandir, lstat, top):
|
||||||
try:
|
try:
|
||||||
yield [fsdec(name), fun(abspath)]
|
yield [fsdec(name), fun(abspath)]
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
logger(src, "stat {} @ {}".format(repr(ex), fsdec(abspath)), 6)
|
logger(src, "[s] {} @ {}".format(repr(ex), fsdec(abspath)), 6)
|
||||||
|
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
logger(src, "{} @ {}".format(repr(ex), top), 1)
|
logger(src, "{} @ {}".format(repr(ex), top), 1)
|
||||||
|
|
Loading…
Reference in a new issue