remote-run-everything 2.0.4__py3-none-any.whl → 2.0.6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- remote_run_everything/__init__.py +0 -1
- remote_run_everything/db/crude_duck.py +3 -0
- remote_run_everything/deploy/by_http.py +12 -23
- remote_run_everything/deploy/by_http_tool.py +37 -11
- {remote_run_everything-2.0.4.dist-info → remote_run_everything-2.0.6.dist-info}/METADATA +1 -1
- {remote_run_everything-2.0.4.dist-info → remote_run_everything-2.0.6.dist-info}/RECORD +9 -10
- remote_run_everything/deploy/by_http_server.py +0 -56
- {remote_run_everything-2.0.4.dist-info → remote_run_everything-2.0.6.dist-info}/WHEEL +0 -0
- {remote_run_everything-2.0.4.dist-info → remote_run_everything-2.0.6.dist-info}/licenses/LICENSE +0 -0
- {remote_run_everything-2.0.4.dist-info → remote_run_everything-2.0.6.dist-info}/top_level.txt +0 -0
|
@@ -48,6 +48,9 @@ class CrudeDuck:
|
|
|
48
48
|
scheme = {i[0]: i[1] for i in con.sql(sql).fetchall()}
|
|
49
49
|
return scheme
|
|
50
50
|
|
|
51
|
+
def quot_comma(self, l):
|
|
52
|
+
return ','.join([f"'{i}'" for i in l])
|
|
53
|
+
|
|
51
54
|
def max_id(self, con, table):
|
|
52
55
|
sql = f'select max(id) from {table}'
|
|
53
56
|
a = con.sql(sql).fetchone()
|
|
@@ -29,17 +29,20 @@ class ByHttp:
|
|
|
29
29
|
sql = f"select * from down where path='{path}' and time='{t}' "
|
|
30
30
|
res = con.sql(sql).fetchone()
|
|
31
31
|
if res is not None: continue
|
|
32
|
+
ok=self.t.pull(self.host, path, self.local, self.remote)
|
|
33
|
+
if ok!="ok":
|
|
34
|
+
print ("err==",ok,dic)
|
|
35
|
+
continue
|
|
32
36
|
print("down", dic)
|
|
33
37
|
con.execute(f"delete from down where path='{path}' ")
|
|
34
|
-
self.t.pull(self.host, path, self.local, self.remote)
|
|
35
38
|
add_l.append(dic)
|
|
36
39
|
con.commit()
|
|
37
40
|
c.insert_many(eg, mod, add_l)
|
|
38
41
|
|
|
39
42
|
def up(self, disallow_keys=None):
|
|
40
|
-
if os.name == "nt":
|
|
41
|
-
|
|
42
|
-
assert self.dbpath.endswith(".db"), "dbpath should be xxx.db"
|
|
43
|
+
# if os.name == "nt":
|
|
44
|
+
# return self.up_win(disallow_keys)
|
|
45
|
+
# assert self.dbpath.endswith(".db"), "dbpath should be xxx.db"
|
|
43
46
|
c = Crud()
|
|
44
47
|
eg = c.sqlite_engine(self.dbpath)
|
|
45
48
|
c.create_table(eg, Up)
|
|
@@ -53,30 +56,16 @@ class ByHttp:
|
|
|
53
56
|
sql = f"select * from up where path='{path}' and time='{t}' and host='{self.host}' "
|
|
54
57
|
res = con.sql(sql).fetchone()
|
|
55
58
|
if res is not None: continue
|
|
59
|
+
ok=self.t.push(self.host, path, self.local, self.remote)
|
|
60
|
+
if ok!="ok":
|
|
61
|
+
print ("err==",ok,dic)
|
|
62
|
+
continue
|
|
56
63
|
print("up==", dic)
|
|
57
64
|
sql = f"delete from up where path='{path}' and host='{self.host}'"
|
|
58
65
|
con.execute(sql).commit()
|
|
59
|
-
self.t.push(self.host, path, self.local, self.remote)
|
|
60
66
|
dic['host'] = self.host
|
|
61
67
|
add_l.append(dic)
|
|
62
68
|
con.commit()
|
|
63
69
|
c.insert_many(eg, mod, add_l)
|
|
64
70
|
|
|
65
|
-
|
|
66
|
-
from mongo_emb import PyMongoEmb
|
|
67
|
-
if not os.path.exists(self.dbpath):
|
|
68
|
-
os.makedirs(self.dbpath)
|
|
69
|
-
assert os.path.isdir(self.dbpath), "dbpath should be dir"
|
|
70
|
-
path = os.path.normpath(self.dbpath)
|
|
71
|
-
db = PyMongoEmb(path)
|
|
72
|
-
col = db['up']
|
|
73
|
-
loc_files = self.t.all_local_path(self.local, disallow_keys)
|
|
74
|
-
for dic in loc_files:
|
|
75
|
-
dic['host'] = self.host
|
|
76
|
-
# time path host
|
|
77
|
-
if col.find_one(dic) is not None:
|
|
78
|
-
continue
|
|
79
|
-
if os.path.normpath(os.path.dirname(dic['path'])) == path: continue
|
|
80
|
-
self.t.push(self.host, dic['path'], self.local, self.remote)
|
|
81
|
-
print("up==", dic)
|
|
82
|
-
col.update_one({"host": self.host, "path": dic['path']}, {"$set": {"time": dic['time']}}, upsert=True)
|
|
71
|
+
|
|
@@ -5,19 +5,27 @@ import os, glob, arrow, requests
|
|
|
5
5
|
|
|
6
6
|
class ByHttpTool:
|
|
7
7
|
def push(self, host, f, local, remote):
|
|
8
|
-
b64 = Common().readb64(f)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
# b64 = Common().readb64(f)
|
|
9
|
+
# push_url = f"{host}/wb64"
|
|
10
|
+
# pay = {"b64": b64, "path": path}
|
|
11
|
+
# res = requests.post(push_url, json=pay).json()
|
|
12
|
+
rpath = self.loc2remote(f, local, remote)
|
|
13
|
+
lpath = f
|
|
14
|
+
return self.upload_file(host, rpath, lpath)
|
|
15
|
+
|
|
14
16
|
|
|
15
17
|
def pull(self, host, f, local, remote):
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
rpath = f
|
|
19
|
+
lpath = self.remote2loc(f, local, remote)
|
|
20
|
+
try:
|
|
21
|
+
self.download_file(host, rpath, lpath)
|
|
22
|
+
return "ok"
|
|
23
|
+
except Exception as e:
|
|
24
|
+
return str(e)
|
|
25
|
+
# res = requests.post(f"{host}/rb64", json={"path": f}).json()
|
|
26
|
+
# b64 = res['data']
|
|
27
|
+
# path = self.remote2loc(f, local, remote)
|
|
28
|
+
# Common().writeb64(path, b64)
|
|
21
29
|
|
|
22
30
|
def all_remote_path(self, host, root, disallow_keys=None):
|
|
23
31
|
url = f"{host}/iterdir"
|
|
@@ -62,3 +70,21 @@ class ByHttpTool:
|
|
|
62
70
|
def remote2loc(self, f, local, remote):
|
|
63
71
|
rela = os.path.relpath(f, remote)
|
|
64
72
|
return f"{local}/{rela}"
|
|
73
|
+
|
|
74
|
+
def download_file(self, host, rpath, lpath):
|
|
75
|
+
ldir = os.path.dirname(lpath)
|
|
76
|
+
os.makedirs(ldir, exist_ok=True)
|
|
77
|
+
url = f"{host}/downfile"
|
|
78
|
+
pay = {"path": rpath}
|
|
79
|
+
# NOTE the stream=True parameter below
|
|
80
|
+
with requests.post(url, data=pay, stream=True) as r:
|
|
81
|
+
r.raise_for_status()
|
|
82
|
+
with open(lpath, 'wb') as f:
|
|
83
|
+
for chunk in r.iter_content(chunk_size=8192):
|
|
84
|
+
f.write(chunk)
|
|
85
|
+
|
|
86
|
+
def upload_file(self, host, rpath, lpath):
|
|
87
|
+
url = f"{host}/upfile"
|
|
88
|
+
files = {'files': open(lpath, 'rb')}
|
|
89
|
+
r = requests.post(url, files=files, data={'path': rpath}).json()
|
|
90
|
+
return r['status']
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
remote_run_everything/__init__.py,sha256=
|
|
1
|
+
remote_run_everything/__init__.py,sha256=s0ZYAkpui5x47uOzKMkghoVW9-yW6Y4xvoEntyB0_cc,760
|
|
2
2
|
remote_run_everything/db/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
3
|
remote_run_everything/db/backup.py,sha256=_mDUNQo1q6Gc75-diwadrooZsdV89KGG9mIcS4rmcBQ,1152
|
|
4
4
|
remote_run_everything/db/crud_sqlalchemy.py,sha256=cDyDGHwE-1TUBZrXMVDTjIa4Z0ZUQvM9m9sk-eIwaSM,5192
|
|
5
|
-
remote_run_everything/db/crude_duck.py,sha256=
|
|
5
|
+
remote_run_everything/db/crude_duck.py,sha256=OYkE26_Js_PFr0DoBOBCZ6tYxsp7BhhNvGMn7-rJgWA,4370
|
|
6
6
|
remote_run_everything/db/kv_store.py,sha256=Df2Lp2l5ip0YQuTdVnlQbkZT_Sz01j9D5bJ8PYaSFRY,3357
|
|
7
7
|
remote_run_everything/deploy/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
-
remote_run_everything/deploy/by_http.py,sha256=
|
|
9
|
-
remote_run_everything/deploy/
|
|
10
|
-
remote_run_everything/deploy/by_http_tool.py,sha256=x2GUi7x4MIhTcaxIsk-nXDQBgUdSO_rSN5z81bnEAoA,2178
|
|
8
|
+
remote_run_everything/deploy/by_http.py,sha256=QWL3XqLTbp9O2WadPX59uR1fGJdgd9xzg1Pv8CuxfbQ,2661
|
|
9
|
+
remote_run_everything/deploy/by_http_tool.py,sha256=H_-OvpayNVGG9e93Qnq5SCT0CsDbCEVtiA2kF2XVQ8U,3166
|
|
11
10
|
remote_run_everything/deploy/record_mod.py,sha256=29L-RTnvANpjbWRND7GGz5sdCzbz1Ba9QxdS858bdAY,725
|
|
12
11
|
remote_run_everything/nosql/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
12
|
remote_run_everything/nosql/no_sql.py,sha256=1-dT6LhrayQqLqZ4ES2tmWfXYCEXOnqwNzKgyXWYRG4,2343
|
|
@@ -21,8 +20,8 @@ remote_run_everything/tools/decorators.py,sha256=SIacNAs7afgkU0D09J-s-YscCVnxSG8
|
|
|
21
20
|
remote_run_everything/tools/sqlacodegen_go_struct.py,sha256=0xWJVCjFyEF2VjC1aGo6DmIqEQQ0Q46CfBAb9FSCUuE,3237
|
|
22
21
|
remote_run_everything/vsconf/conf_txt.py,sha256=nhFuKLlts-sCIBmfr0IKv1pP-qPUvQQrsRRg21q5Gd4,2418
|
|
23
22
|
remote_run_everything/vsconf/core.py,sha256=HmSEzXjGPY7R64rwfAV024YxMHwmBkLin6lGace4U0M,833
|
|
24
|
-
remote_run_everything-2.0.
|
|
25
|
-
remote_run_everything-2.0.
|
|
26
|
-
remote_run_everything-2.0.
|
|
27
|
-
remote_run_everything-2.0.
|
|
28
|
-
remote_run_everything-2.0.
|
|
23
|
+
remote_run_everything-2.0.6.dist-info/licenses/LICENSE,sha256=6kbiFSfobTZ7beWiKnHpN902HgBx-Jzgcme0SvKqhKY,1091
|
|
24
|
+
remote_run_everything-2.0.6.dist-info/METADATA,sha256=y5vDF98lRt0ZfgIpzrh3byYsG-rmkhq8nM2AWVLtiOQ,3121
|
|
25
|
+
remote_run_everything-2.0.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
26
|
+
remote_run_everything-2.0.6.dist-info/top_level.txt,sha256=1TUcAqPgSwiVBqUHz-1pZFXvRpr9cudEYlmfw_mztRY,22
|
|
27
|
+
remote_run_everything-2.0.6.dist-info/RECORD,,
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import cherrypy
|
|
2
|
-
from remote_run_everything.deploy.by_http_tool import ByHttpTool
|
|
3
|
-
from remote_run_everything.tools.common import Common
|
|
4
|
-
|
|
5
|
-
from cherrypy.process.plugins import Daemonizer
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
def cherrypy_in_daemon(myapp, port, prefix):
|
|
9
|
-
cherrypy.config.update({
|
|
10
|
-
"server.socket_port": port,
|
|
11
|
-
})
|
|
12
|
-
Daemonizer(cherrypy.engine).subscribe()
|
|
13
|
-
cherrypy.tree.mount(myapp(), prefix)
|
|
14
|
-
cherrypy.engine.start()
|
|
15
|
-
cherrypy.engine.block()
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
class ByHttpServer:
|
|
19
|
-
|
|
20
|
-
@cherrypy.expose
|
|
21
|
-
@cherrypy.tools.json_out()
|
|
22
|
-
@cherrypy.tools.json_in()
|
|
23
|
-
def rb64(self):
|
|
24
|
-
try:
|
|
25
|
-
args = cherrypy.request.json
|
|
26
|
-
path = args['path']
|
|
27
|
-
data = Common().readb64(path)
|
|
28
|
-
return {"status": "ok", "data": data}
|
|
29
|
-
except Exception as e:
|
|
30
|
-
return {"status": "fail", "data": str(e)}
|
|
31
|
-
|
|
32
|
-
@cherrypy.expose
|
|
33
|
-
@cherrypy.tools.json_out()
|
|
34
|
-
@cherrypy.tools.json_in()
|
|
35
|
-
def wb64(self):
|
|
36
|
-
try:
|
|
37
|
-
args = cherrypy.request.json
|
|
38
|
-
path = args['path']
|
|
39
|
-
b64 = args['b64']
|
|
40
|
-
Common().writeb64(path, b64)
|
|
41
|
-
return {"status": "ok", "data": path}
|
|
42
|
-
except Exception as e:
|
|
43
|
-
return {"status": "fail", "data": str(e)}
|
|
44
|
-
|
|
45
|
-
@cherrypy.expose
|
|
46
|
-
@cherrypy.tools.json_out()
|
|
47
|
-
@cherrypy.tools.json_in()
|
|
48
|
-
def iterdir(self):
|
|
49
|
-
try:
|
|
50
|
-
args = cherrypy.request.json
|
|
51
|
-
root = args['root']
|
|
52
|
-
disallow = args.get("disallow_keys", [])
|
|
53
|
-
data = ByHttpTool().all_local_path(root, disallow)
|
|
54
|
-
return {"status": "ok", "data": data}
|
|
55
|
-
except Exception as e:
|
|
56
|
-
return {"status": "fail", "data": str(e)}
|
|
File without changes
|
{remote_run_everything-2.0.4.dist-info → remote_run_everything-2.0.6.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
{remote_run_everything-2.0.4.dist-info → remote_run_everything-2.0.6.dist-info}/top_level.txt
RENAMED
|
File without changes
|