mirror of
				https://github.com/9001/copyparty.git
				synced 2025-11-03 21:43:12 +00:00 
			
		
		
		
	utcfromtimestamp was deprecated and nobody told me,
not even the deprecationwarning that got silently generated burning 20~30% of all CPU-time without actually displaying it anywhere, nice python 3.12.0 is now only 5% slower than 3.11.6 also fixes some other, less-performance-fatal deprecations
This commit is contained in:
		
							
								
								
									
										4
									
								
								.vscode/launch.json
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								.vscode/launch.json
									
									
									
									
										vendored
									
									
								
							@@ -9,6 +9,10 @@
 | 
				
			|||||||
            "console": "integratedTerminal",
 | 
					            "console": "integratedTerminal",
 | 
				
			||||||
            "cwd": "${workspaceFolder}",
 | 
					            "cwd": "${workspaceFolder}",
 | 
				
			||||||
            "justMyCode": false,
 | 
					            "justMyCode": false,
 | 
				
			||||||
 | 
					            "env": {
 | 
				
			||||||
 | 
					                "PYDEVD_DISABLE_FILE_VALIDATION": "1",
 | 
				
			||||||
 | 
					                "PYTHONWARNINGS": "always", //error
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
            "args": [
 | 
					            "args": [
 | 
				
			||||||
                //"-nw",
 | 
					                //"-nw",
 | 
				
			||||||
                "-ed",
 | 
					                "-ed",
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								.vscode/launch.py
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.vscode/launch.py
									
									
									
									
										vendored
									
									
								
							@@ -41,7 +41,7 @@ if sfx:
 | 
				
			|||||||
    argv = [sys.executable, sfx] + argv
 | 
					    argv = [sys.executable, sfx] + argv
 | 
				
			||||||
    sp.check_call(argv)
 | 
					    sp.check_call(argv)
 | 
				
			||||||
elif re.search(" -j ?[0-9]", " ".join(argv)):
 | 
					elif re.search(" -j ?[0-9]", " ".join(argv)):
 | 
				
			||||||
    argv = [sys.executable, "-m", "copyparty"] + argv
 | 
					    argv = [sys.executable, "-Wa", "-m", "copyparty"] + argv
 | 
				
			||||||
    sp.check_call(argv)
 | 
					    sp.check_call(argv)
 | 
				
			||||||
else:
 | 
					else:
 | 
				
			||||||
    sys.path.insert(0, os.getcwd())
 | 
					    sys.path.insert(0, os.getcwd())
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										1
									
								
								.vscode/tasks.json
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.vscode/tasks.json
									
									
									
									
										vendored
									
									
								
							@@ -11,6 +11,7 @@
 | 
				
			|||||||
            "type": "shell",
 | 
					            "type": "shell",
 | 
				
			||||||
            "command": "${config:python.pythonPath}",
 | 
					            "command": "${config:python.pythonPath}",
 | 
				
			||||||
            "args": [
 | 
					            "args": [
 | 
				
			||||||
 | 
					                "-Wa", //-We
 | 
				
			||||||
                ".vscode/launch.py"
 | 
					                ".vscode/launch.py"
 | 
				
			||||||
            ]
 | 
					            ]
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,7 +7,11 @@ import json
 | 
				
			|||||||
import os
 | 
					import os
 | 
				
			||||||
import sys
 | 
					import sys
 | 
				
			||||||
import time
 | 
					import time
 | 
				
			||||||
from datetime import datetime
 | 
					
 | 
				
			||||||
 | 
					try:
 | 
				
			||||||
 | 
					    from datetime import datetime, timezone
 | 
				
			||||||
 | 
					except:
 | 
				
			||||||
 | 
					    from datetime import datetime
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
@@ -96,7 +100,11 @@ def main(argv=None):
 | 
				
			|||||||
    msg_info = json.loads(sys.argv[1])
 | 
					    msg_info = json.loads(sys.argv[1])
 | 
				
			||||||
    # print(msg_info)
 | 
					    # print(msg_info)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    dt = datetime.utcfromtimestamp(msg_info["at"])
 | 
					    try:
 | 
				
			||||||
 | 
					        dt = datetime.fromtimestamp(msg_info["at"], timezone.utc)
 | 
				
			||||||
 | 
					    except:
 | 
				
			||||||
 | 
					        dt = datetime.utcfromtimestamp(msg_info["at"])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    msg_info["datetime"] = dt.strftime("%Y-%m-%d, %H:%M:%S")
 | 
					    msg_info["datetime"] = dt.strftime("%Y-%m-%d, %H:%M:%S")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    msg_text = TEMPLATE % msg_info
 | 
					    msg_text = TEMPLATE % msg_info
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,7 +4,7 @@ import json
 | 
				
			|||||||
import os
 | 
					import os
 | 
				
			||||||
import sys
 | 
					import sys
 | 
				
			||||||
import subprocess as sp
 | 
					import subprocess as sp
 | 
				
			||||||
from datetime import datetime
 | 
					from datetime import datetime, timezone
 | 
				
			||||||
from plyer import notification
 | 
					from plyer import notification
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -43,7 +43,8 @@ def main():
 | 
				
			|||||||
    fp = inf["ap"]
 | 
					    fp = inf["ap"]
 | 
				
			||||||
    sz = humansize(inf["sz"])
 | 
					    sz = humansize(inf["sz"])
 | 
				
			||||||
    dp, fn = os.path.split(fp)
 | 
					    dp, fn = os.path.split(fp)
 | 
				
			||||||
    mt = datetime.utcfromtimestamp(inf["mt"]).strftime("%Y-%m-%d %H:%M:%S")
 | 
					    dt = datetime.fromtimestamp(inf["mt"], timezone.utc)
 | 
				
			||||||
 | 
					    mt = dt.strftime("%Y-%m-%d %H:%M:%S")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    msg = f"{fn} ({sz})\n📁 {dp}"
 | 
					    msg = f"{fn} ({sz})\n📁 {dp}"
 | 
				
			||||||
    title = "File received"
 | 
					    title = "File received"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,7 +3,7 @@
 | 
				
			|||||||
import hashlib
 | 
					import hashlib
 | 
				
			||||||
import json
 | 
					import json
 | 
				
			||||||
import sys
 | 
					import sys
 | 
				
			||||||
from datetime import datetime
 | 
					from datetime import datetime, timezone
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
_ = r"""
 | 
					_ = r"""
 | 
				
			||||||
@@ -43,8 +43,11 @@ except:
 | 
				
			|||||||
        return p
 | 
					        return p
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					UTC = timezone.utc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def humantime(ts):
 | 
					def humantime(ts):
 | 
				
			||||||
    return datetime.utcfromtimestamp(ts).strftime("%Y-%m-%d %H:%M:%S")
 | 
					    return datetime.fromtimestamp(ts, UTC).strftime("%Y-%m-%d %H:%M:%S")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def find_files_root(inf):
 | 
					def find_files_root(inf):
 | 
				
			||||||
@@ -96,7 +99,7 @@ def main():
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    ret.append("# {} files, {} bytes total".format(len(inf), total_sz))
 | 
					    ret.append("# {} files, {} bytes total".format(len(inf), total_sz))
 | 
				
			||||||
    ret.append("")
 | 
					    ret.append("")
 | 
				
			||||||
    ftime = datetime.utcnow().strftime("%Y-%m%d-%H%M%S.%f")
 | 
					    ftime = datetime.now(UTC).strftime("%Y-%m%d-%H%M%S.%f")
 | 
				
			||||||
    fp = "{}xfer-{}.sha512".format(inf[0]["ap"][:di], ftime)
 | 
					    fp = "{}xfer-{}.sha512".format(inf[0]["ap"][:di], ftime)
 | 
				
			||||||
    with open(fsenc(fp), "wb") as f:
 | 
					    with open(fsenc(fp), "wb") as f:
 | 
				
			||||||
        f.write("\n".join(ret).encode("utf-8", "replace"))
 | 
					        f.write("\n".join(ret).encode("utf-8", "replace"))
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -46,12 +46,13 @@ import traceback
 | 
				
			|||||||
import http.client  # py2: httplib
 | 
					import http.client  # py2: httplib
 | 
				
			||||||
import urllib.parse
 | 
					import urllib.parse
 | 
				
			||||||
import calendar
 | 
					import calendar
 | 
				
			||||||
from datetime import datetime
 | 
					from datetime import datetime, timezone
 | 
				
			||||||
from urllib.parse import quote_from_bytes as quote
 | 
					from urllib.parse import quote_from_bytes as quote
 | 
				
			||||||
from urllib.parse import unquote_to_bytes as unquote
 | 
					from urllib.parse import unquote_to_bytes as unquote
 | 
				
			||||||
 | 
					
 | 
				
			||||||
WINDOWS = sys.platform == "win32"
 | 
					WINDOWS = sys.platform == "win32"
 | 
				
			||||||
MACOS = platform.system() == "Darwin"
 | 
					MACOS = platform.system() == "Darwin"
 | 
				
			||||||
 | 
					UTC = timezone.utc
 | 
				
			||||||
info = log = dbg = None
 | 
					info = log = dbg = None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -176,7 +177,7 @@ class RecentLog(object):
 | 
				
			|||||||
    def put(self, msg):
 | 
					    def put(self, msg):
 | 
				
			||||||
        msg = "{:10.6f} {} {}\n".format(time.time() % 900, rice_tid(), msg)
 | 
					        msg = "{:10.6f} {} {}\n".format(time.time() % 900, rice_tid(), msg)
 | 
				
			||||||
        if self.f:
 | 
					        if self.f:
 | 
				
			||||||
            fmsg = " ".join([datetime.utcnow().strftime("%H%M%S.%f"), str(msg)])
 | 
					            fmsg = " ".join([datetime.now(UTC).strftime("%H%M%S.%f"), str(msg)])
 | 
				
			||||||
            self.f.write(fmsg.encode("utf-8"))
 | 
					            self.f.write(fmsg.encode("utf-8"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        with self.mtx:
 | 
					        with self.mtx:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -20,12 +20,13 @@ import sys
 | 
				
			|||||||
import base64
 | 
					import base64
 | 
				
			||||||
import sqlite3
 | 
					import sqlite3
 | 
				
			||||||
import argparse
 | 
					import argparse
 | 
				
			||||||
from datetime import datetime
 | 
					from datetime import datetime, timezone
 | 
				
			||||||
from urllib.parse import quote_from_bytes as quote
 | 
					from urllib.parse import quote_from_bytes as quote
 | 
				
			||||||
from urllib.parse import unquote_to_bytes as unquote
 | 
					from urllib.parse import unquote_to_bytes as unquote
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
FS_ENCODING = sys.getfilesystemencoding()
 | 
					FS_ENCODING = sys.getfilesystemencoding()
 | 
				
			||||||
 | 
					UTC = timezone.utc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class APF(argparse.ArgumentDefaultsHelpFormatter, argparse.RawDescriptionHelpFormatter):
 | 
					class APF(argparse.ArgumentDefaultsHelpFormatter, argparse.RawDescriptionHelpFormatter):
 | 
				
			||||||
@@ -155,11 +156,10 @@ th {
 | 
				
			|||||||
                link = txt.decode("utf-8")[4:]
 | 
					                link = txt.decode("utf-8")[4:]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        sz = "{:,}".format(sz)
 | 
					        sz = "{:,}".format(sz)
 | 
				
			||||||
 | 
					        dt = datetime.fromtimestamp(at if at > 0 else mt, UTC)
 | 
				
			||||||
        v = [
 | 
					        v = [
 | 
				
			||||||
            w[:16],
 | 
					            w[:16],
 | 
				
			||||||
            datetime.utcfromtimestamp(at if at > 0 else mt).strftime(
 | 
					            dt.strftime("%Y-%m-%d %H:%M:%S"),
 | 
				
			||||||
                "%Y-%m-%d %H:%M:%S"
 | 
					 | 
				
			||||||
            ),
 | 
					 | 
				
			||||||
            sz,
 | 
					            sz,
 | 
				
			||||||
            imap.get(ip, ip),
 | 
					            imap.get(ip, ip),
 | 
				
			||||||
        ]
 | 
					        ]
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -186,7 +186,10 @@ def init_E(E: EnvParams) -> None:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        with open_binary("copyparty", "z.tar") as tgz:
 | 
					        with open_binary("copyparty", "z.tar") as tgz:
 | 
				
			||||||
            with tarfile.open(fileobj=tgz) as tf:
 | 
					            with tarfile.open(fileobj=tgz) as tf:
 | 
				
			||||||
                tf.extractall(tdn)  # nosec (archive is safe)
 | 
					                try:
 | 
				
			||||||
 | 
					                    tf.extractall(tdn, filter="tar")
 | 
				
			||||||
 | 
					                except TypeError:
 | 
				
			||||||
 | 
					                    tf.extractall(tdn)  # nosec (archive is safe)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return tdn
 | 
					        return tdn
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -23,6 +23,7 @@ from .util import (
 | 
				
			|||||||
    UNPLICATIONS,
 | 
					    UNPLICATIONS,
 | 
				
			||||||
    ODict,
 | 
					    ODict,
 | 
				
			||||||
    Pebkac,
 | 
					    Pebkac,
 | 
				
			||||||
 | 
					    UTC,
 | 
				
			||||||
    absreal,
 | 
					    absreal,
 | 
				
			||||||
    afsenc,
 | 
					    afsenc,
 | 
				
			||||||
    get_df,
 | 
					    get_df,
 | 
				
			||||||
@@ -215,7 +216,7 @@ class Lim(object):
 | 
				
			|||||||
            if self.rot_re.search(path.replace("\\", "/")):
 | 
					            if self.rot_re.search(path.replace("\\", "/")):
 | 
				
			||||||
                return path, ""
 | 
					                return path, ""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            suf = datetime.utcnow().strftime(self.rotf)
 | 
					            suf = datetime.now(UTC).strftime(self.rotf)
 | 
				
			||||||
            if path:
 | 
					            if path:
 | 
				
			||||||
                path += "/"
 | 
					                path += "/"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -42,6 +42,7 @@ from .util import (
 | 
				
			|||||||
    MultipartParser,
 | 
					    MultipartParser,
 | 
				
			||||||
    ODict,
 | 
					    ODict,
 | 
				
			||||||
    Pebkac,
 | 
					    Pebkac,
 | 
				
			||||||
 | 
					    UTC,
 | 
				
			||||||
    UnrecvEOF,
 | 
					    UnrecvEOF,
 | 
				
			||||||
    absreal,
 | 
					    absreal,
 | 
				
			||||||
    alltrace,
 | 
					    alltrace,
 | 
				
			||||||
@@ -3992,7 +3993,7 @@ class HttpCli(object):
 | 
				
			|||||||
                margin = "-"
 | 
					                margin = "-"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            sz = inf.st_size
 | 
					            sz = inf.st_size
 | 
				
			||||||
            zd = datetime.utcfromtimestamp(linf.st_mtime)
 | 
					            zd = datetime.fromtimestamp(linf.st_mtime, UTC)
 | 
				
			||||||
            dt = "%04d-%02d-%02d %02d:%02d:%02d" % (
 | 
					            dt = "%04d-%02d-%02d %02d:%02d:%02d" % (
 | 
				
			||||||
                zd.year,
 | 
					                zd.year,
 | 
				
			||||||
                zd.month,
 | 
					                zd.month,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,7 +8,7 @@ from datetime import datetime
 | 
				
			|||||||
from .__init__ import CORES
 | 
					from .__init__ import CORES
 | 
				
			||||||
from .bos import bos
 | 
					from .bos import bos
 | 
				
			||||||
from .th_cli import ThumbCli
 | 
					from .th_cli import ThumbCli
 | 
				
			||||||
from .util import vjoin
 | 
					from .util import UTC, vjoin
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if True:  # pylint: disable=using-constant-test
 | 
					if True:  # pylint: disable=using-constant-test
 | 
				
			||||||
    from typing import Any, Generator, Optional
 | 
					    from typing import Any, Generator, Optional
 | 
				
			||||||
@@ -108,7 +108,7 @@ def errdesc(errors: list[tuple[str, str]]) -> tuple[dict[str, Any], list[str]]:
 | 
				
			|||||||
        tf_path = tf.name
 | 
					        tf_path = tf.name
 | 
				
			||||||
        tf.write("\r\n".join(report).encode("utf-8", "replace"))
 | 
					        tf.write("\r\n".join(report).encode("utf-8", "replace"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    dt = datetime.utcnow().strftime("%Y-%m%d-%H%M%S")
 | 
					    dt = datetime.now(UTC).strftime("%Y-%m%d-%H%M%S")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    bos.chmod(tf_path, 0o444)
 | 
					    bos.chmod(tf_path, 0o444)
 | 
				
			||||||
    return {
 | 
					    return {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -45,6 +45,7 @@ from .util import (
 | 
				
			|||||||
    HLog,
 | 
					    HLog,
 | 
				
			||||||
    HMaccas,
 | 
					    HMaccas,
 | 
				
			||||||
    ODict,
 | 
					    ODict,
 | 
				
			||||||
 | 
					    UTC,
 | 
				
			||||||
    alltrace,
 | 
					    alltrace,
 | 
				
			||||||
    ansi_re,
 | 
					    ansi_re,
 | 
				
			||||||
    min_ex,
 | 
					    min_ex,
 | 
				
			||||||
@@ -484,7 +485,7 @@ class SvcHub(object):
 | 
				
			|||||||
            self.args.nc = min(self.args.nc, soft // 2)
 | 
					            self.args.nc = min(self.args.nc, soft // 2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def _logname(self) -> str:
 | 
					    def _logname(self) -> str:
 | 
				
			||||||
        dt = datetime.utcnow()
 | 
					        dt = datetime.now(UTC)
 | 
				
			||||||
        fn = str(self.args.lo)
 | 
					        fn = str(self.args.lo)
 | 
				
			||||||
        for fs in "YmdHMS":
 | 
					        for fs in "YmdHMS":
 | 
				
			||||||
            fs = "%" + fs
 | 
					            fs = "%" + fs
 | 
				
			||||||
@@ -733,7 +734,7 @@ class SvcHub(object):
 | 
				
			|||||||
            return
 | 
					            return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        with self.log_mutex:
 | 
					        with self.log_mutex:
 | 
				
			||||||
            zd = datetime.utcnow()
 | 
					            zd = datetime.now(UTC)
 | 
				
			||||||
            ts = self.log_dfmt % (
 | 
					            ts = self.log_dfmt % (
 | 
				
			||||||
                zd.year,
 | 
					                zd.year,
 | 
				
			||||||
                zd.month * 100 + zd.day,
 | 
					                zd.month * 100 + zd.day,
 | 
				
			||||||
@@ -751,7 +752,7 @@ class SvcHub(object):
 | 
				
			|||||||
            self.logf.close()
 | 
					            self.logf.close()
 | 
				
			||||||
            self._setup_logfile("")
 | 
					            self._setup_logfile("")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        dt = datetime.utcnow()
 | 
					        dt = datetime.now(UTC)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # unix timestamp of next 00:00:00 (leap-seconds safe)
 | 
					        # unix timestamp of next 00:00:00 (leap-seconds safe)
 | 
				
			||||||
        day_now = dt.day
 | 
					        day_now = dt.day
 | 
				
			||||||
@@ -759,14 +760,20 @@ class SvcHub(object):
 | 
				
			|||||||
            dt += timedelta(hours=12)
 | 
					            dt += timedelta(hours=12)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        dt = dt.replace(hour=0, minute=0, second=0)
 | 
					        dt = dt.replace(hour=0, minute=0, second=0)
 | 
				
			||||||
        self.next_day = calendar.timegm(dt.utctimetuple())
 | 
					        try:
 | 
				
			||||||
 | 
					            tt = dt.utctimetuple()
 | 
				
			||||||
 | 
					        except:
 | 
				
			||||||
 | 
					            # still makes me hella uncomfortable
 | 
				
			||||||
 | 
					            tt = dt.timetuple()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        self.next_day = calendar.timegm(tt)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def _log_enabled(self, src: str, msg: str, c: Union[int, str] = 0) -> None:
 | 
					    def _log_enabled(self, src: str, msg: str, c: Union[int, str] = 0) -> None:
 | 
				
			||||||
        """handles logging from all components"""
 | 
					        """handles logging from all components"""
 | 
				
			||||||
        with self.log_mutex:
 | 
					        with self.log_mutex:
 | 
				
			||||||
            now = time.time()
 | 
					            now = time.time()
 | 
				
			||||||
            if now >= self.next_day:
 | 
					            if now >= self.next_day:
 | 
				
			||||||
                dt = datetime.utcfromtimestamp(now)
 | 
					                dt = datetime.fromtimestamp(now, UTC)
 | 
				
			||||||
                zs = "{}\n" if self.no_ansi else "\033[36m{}\033[0m\n"
 | 
					                zs = "{}\n" if self.no_ansi else "\033[36m{}\033[0m\n"
 | 
				
			||||||
                zs = zs.format(dt.strftime("%Y-%m-%d"))
 | 
					                zs = zs.format(dt.strftime("%Y-%m-%d"))
 | 
				
			||||||
                print(zs, end="")
 | 
					                print(zs, end="")
 | 
				
			||||||
@@ -789,7 +796,7 @@ class SvcHub(object):
 | 
				
			|||||||
                else:
 | 
					                else:
 | 
				
			||||||
                    msg = "%s%s\033[0m" % (c, msg)
 | 
					                    msg = "%s%s\033[0m" % (c, msg)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            zd = datetime.utcfromtimestamp(now)
 | 
					            zd = datetime.fromtimestamp(now, UTC)
 | 
				
			||||||
            ts = self.log_efmt % (
 | 
					            ts = self.log_efmt % (
 | 
				
			||||||
                zd.hour,
 | 
					                zd.hour,
 | 
				
			||||||
                zd.minute,
 | 
					                zd.minute,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -25,7 +25,6 @@ import threading
 | 
				
			|||||||
import time
 | 
					import time
 | 
				
			||||||
import traceback
 | 
					import traceback
 | 
				
			||||||
from collections import Counter
 | 
					from collections import Counter
 | 
				
			||||||
from datetime import datetime
 | 
					 | 
				
			||||||
from email.utils import formatdate
 | 
					from email.utils import formatdate
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from ipaddress import IPv4Address, IPv4Network, IPv6Address, IPv6Network
 | 
					from ipaddress import IPv4Address, IPv4Network, IPv6Address, IPv6Network
 | 
				
			||||||
@@ -35,6 +34,27 @@ from .__init__ import ANYWIN, EXE, MACOS, PY2, TYPE_CHECKING, VT100, WINDOWS
 | 
				
			|||||||
from .__version__ import S_BUILD_DT, S_VERSION
 | 
					from .__version__ import S_BUILD_DT, S_VERSION
 | 
				
			||||||
from .stolen import surrogateescape
 | 
					from .stolen import surrogateescape
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					try:
 | 
				
			||||||
 | 
					    from datetime import datetime, timezone
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    UTC = timezone.utc
 | 
				
			||||||
 | 
					except:
 | 
				
			||||||
 | 
					    from datetime import datetime, timedelta, tzinfo
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    TD_ZERO = timedelta(0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    class _UTC(tzinfo):
 | 
				
			||||||
 | 
					        def utcoffset(self, dt):
 | 
				
			||||||
 | 
					            return TD_ZERO
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        def tzname(self, dt):
 | 
				
			||||||
 | 
					            return "UTC"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        def dst(self, dt):
 | 
				
			||||||
 | 
					            return TD_ZERO
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    UTC = _UTC()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if sys.version_info >= (3, 7) or (
 | 
					if sys.version_info >= (3, 7) or (
 | 
				
			||||||
    sys.version_info >= (3, 6) and platform.python_implementation() == "CPython"
 | 
					    sys.version_info >= (3, 6) and platform.python_implementation() == "CPython"
 | 
				
			||||||
@@ -1131,7 +1151,7 @@ def stackmon(fp: str, ival: float, suffix: str) -> None:
 | 
				
			|||||||
            buf = lzma.compress(buf, preset=0)
 | 
					            buf = lzma.compress(buf, preset=0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if "%" in fp:
 | 
					        if "%" in fp:
 | 
				
			||||||
            dt = datetime.utcnow()
 | 
					            dt = datetime.now(UTC)
 | 
				
			||||||
            for fs in "YmdHMS":
 | 
					            for fs in "YmdHMS":
 | 
				
			||||||
                fs = "%" + fs
 | 
					                fs = "%" + fs
 | 
				
			||||||
                if fs in fp:
 | 
					                if fs in fp:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -295,7 +295,10 @@ def unpack():
 | 
				
			|||||||
        # the only possible input is a single tar.bz2
 | 
					        # the only possible input is a single tar.bz2
 | 
				
			||||||
        # which gets hardcoded into this script at build stage
 | 
					        # which gets hardcoded into this script at build stage
 | 
				
			||||||
        # skip 0
 | 
					        # skip 0
 | 
				
			||||||
        tf.extractall(mine)
 | 
					        try:
 | 
				
			||||||
 | 
					            tf.extractall(mine, filter="tar")
 | 
				
			||||||
 | 
					        except TypeError:
 | 
				
			||||||
 | 
					            tf.extractall(mine)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    os.remove(tar)
 | 
					    os.remove(tar)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -124,7 +124,7 @@ class Cfg(Namespace):
 | 
				
			|||||||
        ex = "df loris re_maxage rproxy rsp_jtr rsp_slp s_wr_slp theme themes turbo"
 | 
					        ex = "df loris re_maxage rproxy rsp_jtr rsp_slp s_wr_slp theme themes turbo"
 | 
				
			||||||
        ka.update(**{k: 0 for k in ex.split()})
 | 
					        ka.update(**{k: 0 for k in ex.split()})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        ex = "ah_alg bname doctitle favico html_head lg_sbf log_fk md_sbf mth name textfiles unlist vname R RS SR"
 | 
					        ex = "ah_alg bname doctitle favico html_head lg_sbf log_fk md_sbf name textfiles unlist vname R RS SR"
 | 
				
			||||||
        ka.update(**{k: "" for k in ex.split()})
 | 
					        ka.update(**{k: "" for k in ex.split()})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        ex = "on403 on404 xad xar xau xban xbd xbr xbu xiu xm"
 | 
					        ex = "on403 on404 xad xar xau xban xbd xbr xbu xiu xm"
 | 
				
			||||||
@@ -141,8 +141,11 @@ class Cfg(Namespace):
 | 
				
			|||||||
            fk_salt="a" * 16,
 | 
					            fk_salt="a" * 16,
 | 
				
			||||||
            unpost=600,
 | 
					            unpost=600,
 | 
				
			||||||
            u2sort="s",
 | 
					            u2sort="s",
 | 
				
			||||||
 | 
					            u2ts="c",
 | 
				
			||||||
 | 
					            sort="href",
 | 
				
			||||||
            mtp=[],
 | 
					            mtp=[],
 | 
				
			||||||
            mte="a",
 | 
					            mte={"a": True},
 | 
				
			||||||
 | 
					            mth={},
 | 
				
			||||||
            lang="eng",
 | 
					            lang="eng",
 | 
				
			||||||
            logout=573,
 | 
					            logout=573,
 | 
				
			||||||
            **ka
 | 
					            **ka
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user