mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 09:02:15 -06:00
black
This commit is contained in:
parent
9405597c15
commit
ec29b59d1e
|
@ -47,21 +47,23 @@ dependencies (windows):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
WINDOWS = sys.platform == 'win32'
|
WINDOWS = sys.platform == "win32"
|
||||||
|
|
||||||
|
|
||||||
def print(*args, **kwargs):
|
def print(*args, **kwargs):
|
||||||
try:
|
try:
|
||||||
builtins.print(*list(args), **kwargs)
|
builtins.print(*list(args), **kwargs)
|
||||||
except:
|
except:
|
||||||
builtins.print(termsafe(' '.join(str(x) for x in args)), **kwargs)
|
builtins.print(termsafe(" ".join(str(x) for x in args)), **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def termsafe(txt):
|
def termsafe(txt):
|
||||||
try:
|
try:
|
||||||
return txt.encode(sys.stdout.encoding, 'backslashreplace').decode(sys.stdout.encoding)
|
return txt.encode(sys.stdout.encoding, "backslashreplace").decode(
|
||||||
|
sys.stdout.encoding
|
||||||
|
)
|
||||||
except:
|
except:
|
||||||
return txt.encode(sys.stdout.encoding, 'replace').decode(sys.stdout.encoding)
|
return txt.encode(sys.stdout.encoding, "replace").decode(sys.stdout.encoding)
|
||||||
|
|
||||||
|
|
||||||
def threadless_log(msg):
|
def threadless_log(msg):
|
||||||
|
@ -100,7 +102,12 @@ def get_tid():
|
||||||
|
|
||||||
|
|
||||||
def html_dec(txt):
|
def html_dec(txt):
|
||||||
return txt.replace('<', '<').replace('>', '>').replace('"', '"').replace('&', '&')
|
return (
|
||||||
|
txt.replace("<", "<")
|
||||||
|
.replace(">", ">")
|
||||||
|
.replace(""", '"')
|
||||||
|
.replace("&", "&")
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class CacheNode(object):
|
class CacheNode(object):
|
||||||
|
@ -565,11 +572,11 @@ class CPPF(Operations):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def getxattr(self, *args):
|
def getxattr(self, *args):
|
||||||
log("@@ getxattr [{}]".format('] ['.join(str(x) for x in args)))
|
log("@@ getxattr [{}]".format("] [".join(str(x) for x in args)))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def listxattr(self, *args):
|
def listxattr(self, *args):
|
||||||
log("@@ listxattr [{}]".format('] ['.join(str(x) for x in args)))
|
log("@@ listxattr [{}]".format("] [".join(str(x) for x in args)))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def open(self, path, flags):
|
def open(self, path, flags):
|
||||||
|
@ -592,7 +599,7 @@ class CPPF(Operations):
|
||||||
log("@@ statfs [{}]".format(path))
|
log("@@ statfs [{}]".format(path))
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
if sys.platform == 'win32':
|
if sys.platform == "win32":
|
||||||
# quick compat for /mingw64/bin/python3 (msys2)
|
# quick compat for /mingw64/bin/python3 (msys2)
|
||||||
def _open(self, path):
|
def _open(self, path):
|
||||||
try:
|
try:
|
||||||
|
@ -658,7 +665,14 @@ def main():
|
||||||
if WINDOWS:
|
if WINDOWS:
|
||||||
os.system("")
|
os.system("")
|
||||||
|
|
||||||
FUSE(CPPF(remote), local, foreground=True, nothreads=True, allow_other=True, nonempty=True)
|
FUSE(
|
||||||
|
CPPF(remote),
|
||||||
|
local,
|
||||||
|
foreground=True,
|
||||||
|
nothreads=True,
|
||||||
|
allow_other=True,
|
||||||
|
nonempty=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
@ -23,9 +23,10 @@ from urllib.parse import quote_from_bytes as quote
|
||||||
try:
|
try:
|
||||||
import fuse
|
import fuse
|
||||||
from fuse import Fuse
|
from fuse import Fuse
|
||||||
|
|
||||||
fuse.fuse_python_api = (0, 2)
|
fuse.fuse_python_api = (0, 2)
|
||||||
if not hasattr(fuse, '__version__'):
|
if not hasattr(fuse, "__version__"):
|
||||||
raise Exception('your fuse-python is way old')
|
raise Exception("your fuse-python is way old")
|
||||||
except:
|
except:
|
||||||
print(
|
print(
|
||||||
"\n could not import fuse; these may help:\n python3 -m pip install --user fuse-python\n apt install libfuse\n modprobe fuse\n"
|
"\n could not import fuse; these may help:\n python3 -m pip install --user fuse-python\n apt install libfuse\n modprobe fuse\n"
|
||||||
|
@ -84,7 +85,12 @@ def get_tid():
|
||||||
|
|
||||||
|
|
||||||
def html_dec(txt):
|
def html_dec(txt):
|
||||||
return txt.replace('<', '<').replace('>', '>').replace('"', '"').replace('&', '&')
|
return (
|
||||||
|
txt.replace("<", "<")
|
||||||
|
.replace(">", ">")
|
||||||
|
.replace(""", '"')
|
||||||
|
.replace("&", "&")
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class CacheNode(object):
|
class CacheNode(object):
|
||||||
|
@ -265,7 +271,7 @@ class CPPF(Fuse):
|
||||||
|
|
||||||
def init2(self):
|
def init2(self):
|
||||||
# TODO figure out how python-fuse wanted this to go
|
# TODO figure out how python-fuse wanted this to go
|
||||||
self.gw = Gateway(self.url) #.decode('utf-8'))
|
self.gw = Gateway(self.url) # .decode('utf-8'))
|
||||||
info("up")
|
info("up")
|
||||||
|
|
||||||
def clean_dircache(self):
|
def clean_dircache(self):
|
||||||
|
@ -487,7 +493,7 @@ class CPPF(Fuse):
|
||||||
|
|
||||||
def readdir(self, path, offset):
|
def readdir(self, path, offset):
|
||||||
for e in self._readdir(path)[offset:]:
|
for e in self._readdir(path)[offset:]:
|
||||||
#log("yield [{}]".format(e[0]))
|
# log("yield [{}]".format(e[0]))
|
||||||
yield fuse.Direntry(e[0])
|
yield fuse.Direntry(e[0])
|
||||||
|
|
||||||
def open(self, path, flags):
|
def open(self, path, flags):
|
||||||
|
@ -564,12 +570,14 @@ def main():
|
||||||
server = CPPF()
|
server = CPPF()
|
||||||
server.parser.add_option(mountopt="url", metavar="BASE_URL", default=None)
|
server.parser.add_option(mountopt="url", metavar="BASE_URL", default=None)
|
||||||
server.parse(values=server, errex=1)
|
server.parse(values=server, errex=1)
|
||||||
if not server.url or not str(server.url).startswith('http'):
|
if not server.url or not str(server.url).startswith("http"):
|
||||||
print('\nerror:')
|
print("\nerror:")
|
||||||
print(' need argument: -o url=<...>')
|
print(" need argument: -o url=<...>")
|
||||||
print(' need argument: mount-path')
|
print(" need argument: mount-path")
|
||||||
print('example:')
|
print("example:")
|
||||||
print(' ./copyparty-fuseb.py -f -o allow_other,auto_unmount,nonempty,url=http://192.168.1.69:3923 /mnt/nas')
|
print(
|
||||||
|
" ./copyparty-fuseb.py -f -o allow_other,auto_unmount,nonempty,url=http://192.168.1.69:3923 /mnt/nas"
|
||||||
|
)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
server.init2()
|
server.init2()
|
||||||
|
|
Loading…
Reference in a new issue