remote-run-everything 2.0.4__tar.gz → 2.0.5__tar.gz

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.
Files changed (35) hide show
  1. {remote_run_everything-2.0.4/remote_run_everything.egg-info → remote_run_everything-2.0.5}/PKG-INFO +1 -1
  2. {remote_run_everything-2.0.4 → remote_run_everything-2.0.5}/pyproject.toml +1 -1
  3. {remote_run_everything-2.0.4 → remote_run_everything-2.0.5}/remote_run_everything/__init__.py +0 -1
  4. {remote_run_everything-2.0.4 → remote_run_everything-2.0.5}/remote_run_everything/db/crude_duck.py +3 -0
  5. {remote_run_everything-2.0.4 → remote_run_everything-2.0.5}/remote_run_everything/deploy/by_http.py +4 -21
  6. {remote_run_everything-2.0.4 → remote_run_everything-2.0.5}/remote_run_everything/deploy/by_http_tool.py +35 -11
  7. {remote_run_everything-2.0.4 → remote_run_everything-2.0.5/remote_run_everything.egg-info}/PKG-INFO +1 -1
  8. {remote_run_everything-2.0.4 → remote_run_everything-2.0.5}/remote_run_everything.egg-info/SOURCES.txt +1 -3
  9. {remote_run_everything-2.0.4 → remote_run_everything-2.0.5}/test/test.py +29 -12
  10. remote_run_everything-2.0.4/remote_run_everything/deploy/by_http_server.py +0 -56
  11. remote_run_everything-2.0.4/test/test_server.py +0 -22
  12. {remote_run_everything-2.0.4 → remote_run_everything-2.0.5}/LICENSE +0 -0
  13. {remote_run_everything-2.0.4 → remote_run_everything-2.0.5}/MANIFEST.in +0 -0
  14. {remote_run_everything-2.0.4 → remote_run_everything-2.0.5}/README.md +0 -0
  15. {remote_run_everything-2.0.4 → remote_run_everything-2.0.5}/remote_run_everything/db/__init__.py +0 -0
  16. {remote_run_everything-2.0.4 → remote_run_everything-2.0.5}/remote_run_everything/db/backup.py +0 -0
  17. {remote_run_everything-2.0.4 → remote_run_everything-2.0.5}/remote_run_everything/db/crud_sqlalchemy.py +0 -0
  18. {remote_run_everything-2.0.4 → remote_run_everything-2.0.5}/remote_run_everything/db/kv_store.py +0 -0
  19. {remote_run_everything-2.0.4 → remote_run_everything-2.0.5}/remote_run_everything/deploy/__init__.py +0 -0
  20. {remote_run_everything-2.0.4 → remote_run_everything-2.0.5}/remote_run_everything/deploy/record_mod.py +0 -0
  21. {remote_run_everything-2.0.4 → remote_run_everything-2.0.5}/remote_run_everything/nosql/__init__.py +0 -0
  22. {remote_run_everything-2.0.4 → remote_run_everything-2.0.5}/remote_run_everything/nosql/no_sql.py +0 -0
  23. {remote_run_everything-2.0.4 → remote_run_everything-2.0.5}/remote_run_everything/nosql/no_sql_mysql.py +0 -0
  24. {remote_run_everything-2.0.4 → remote_run_everything-2.0.5}/remote_run_everything/nosql/no_sql_pg.py +0 -0
  25. {remote_run_everything-2.0.4 → remote_run_everything-2.0.5}/remote_run_everything/nosql/no_sql_tool.py +0 -0
  26. {remote_run_everything-2.0.4 → remote_run_everything-2.0.5}/remote_run_everything/tools/__init__.py +0 -0
  27. {remote_run_everything-2.0.4 → remote_run_everything-2.0.5}/remote_run_everything/tools/common.py +0 -0
  28. {remote_run_everything-2.0.4 → remote_run_everything-2.0.5}/remote_run_everything/tools/common1.py +0 -0
  29. {remote_run_everything-2.0.4 → remote_run_everything-2.0.5}/remote_run_everything/tools/decorators.py +0 -0
  30. {remote_run_everything-2.0.4 → remote_run_everything-2.0.5}/remote_run_everything/tools/sqlacodegen_go_struct.py +0 -0
  31. {remote_run_everything-2.0.4 → remote_run_everything-2.0.5}/remote_run_everything/vsconf/conf_txt.py +0 -0
  32. {remote_run_everything-2.0.4 → remote_run_everything-2.0.5}/remote_run_everything/vsconf/core.py +0 -0
  33. {remote_run_everything-2.0.4 → remote_run_everything-2.0.5}/remote_run_everything.egg-info/dependency_links.txt +0 -0
  34. {remote_run_everything-2.0.4 → remote_run_everything-2.0.5}/remote_run_everything.egg-info/top_level.txt +0 -0
  35. {remote_run_everything-2.0.4 → remote_run_everything-2.0.5}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: remote_run_everything
3
- Version: 2.0.4
3
+ Version: 2.0.5
4
4
  Summary: Deploy Tools
5
5
  Author-email: Wang Qi <wangmarkqi@gmail.com>
6
6
  License-Expression: MIT
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "remote_run_everything"
3
- version = "2.0.4"
3
+ version = "2.0.5"
4
4
  authors = [
5
5
  { name="Wang Qi", email="wangmarkqi@gmail.com" },
6
6
  ]
@@ -1,5 +1,4 @@
1
1
  from remote_run_everything.deploy.by_http import ByHttp
2
- from remote_run_everything.deploy.by_http_server import ByHttpServer, cherrypy_in_daemon
3
2
 
4
3
  from remote_run_everything.db.crude_duck import CrudeDuck
5
4
  from remote_run_everything.db.crud_sqlalchemy import Crud
@@ -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()
@@ -37,9 +37,9 @@ class ByHttp:
37
37
  c.insert_many(eg, mod, add_l)
38
38
 
39
39
  def up(self, disallow_keys=None):
40
- if os.name == "nt":
41
- return self.up_win(disallow_keys)
42
- assert self.dbpath.endswith(".db"), "dbpath should be xxx.db"
40
+ # if os.name == "nt":
41
+ # return self.up_win(disallow_keys)
42
+ # assert self.dbpath.endswith(".db"), "dbpath should be xxx.db"
43
43
  c = Crud()
44
44
  eg = c.sqlite_engine(self.dbpath)
45
45
  c.create_table(eg, Up)
@@ -62,21 +62,4 @@ class ByHttp:
62
62
  con.commit()
63
63
  c.insert_many(eg, mod, add_l)
64
64
 
65
- def up_win(self, disallow_keys=None):
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)
65
+
@@ -5,19 +5,24 @@ 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
- push_url = f"{host}/wb64"
10
- path = self.loc2remote(f, local, remote)
11
- pay = {"b64": b64, "path": path}
12
- res = requests.post(push_url, json=pay).json()
13
- return res
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
+ self.upload_file(host, rpath, lpath)
15
+ return
14
16
 
15
17
  def pull(self, host, f, local, remote):
16
- res = requests.post(f"{host}/rb64", json={"path": f}).json()
17
- b64 = res['data']
18
- path = self.remote2loc(f, local, remote)
19
- Common().writeb64(path, b64)
20
- return path
18
+ rpath = f
19
+ lpath = self.remote2loc(f, local, remote)
20
+ self.download_file(host, rpath, lpath)
21
+ # res = requests.post(f"{host}/rb64", json={"path": f}).json()
22
+ # b64 = res['data']
23
+ # path = self.remote2loc(f, local, remote)
24
+ # Common().writeb64(path, b64)
25
+ return
21
26
 
22
27
  def all_remote_path(self, host, root, disallow_keys=None):
23
28
  url = f"{host}/iterdir"
@@ -62,3 +67,22 @@ class ByHttpTool:
62
67
  def remote2loc(self, f, local, remote):
63
68
  rela = os.path.relpath(f, remote)
64
69
  return f"{local}/{rela}"
70
+
71
+ def download_file(self, host, rpath, lpath):
72
+ ldir = os.path.dirname(lpath)
73
+ os.makedirs(ldir, exist_ok=True)
74
+ url = f"{host}/downfile"
75
+ pay = {"path": rpath}
76
+ # NOTE the stream=True parameter below
77
+ with requests.post(url, data=pay, stream=True) as r:
78
+ r.raise_for_status()
79
+ with open(lpath, 'wb') as f:
80
+ for chunk in r.iter_content(chunk_size=8192):
81
+ f.write(chunk)
82
+
83
+ def upload_file(self, host, rpath, lpath):
84
+ url = f"{host}/upfile"
85
+ files = {'files': open(lpath, 'rb')}
86
+ r = requests.post(url, files=files, data={'path': rpath})
87
+ if "ok" in r.text: return "ok"
88
+ return "fail"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: remote_run_everything
3
- Version: 2.0.4
3
+ Version: 2.0.5
4
4
  Summary: Deploy Tools
5
5
  Author-email: Wang Qi <wangmarkqi@gmail.com>
6
6
  License-Expression: MIT
@@ -14,7 +14,6 @@ remote_run_everything/db/crude_duck.py
14
14
  remote_run_everything/db/kv_store.py
15
15
  remote_run_everything/deploy/__init__.py
16
16
  remote_run_everything/deploy/by_http.py
17
- remote_run_everything/deploy/by_http_server.py
18
17
  remote_run_everything/deploy/by_http_tool.py
19
18
  remote_run_everything/deploy/record_mod.py
20
19
  remote_run_everything/nosql/__init__.py
@@ -29,5 +28,4 @@ remote_run_everything/tools/decorators.py
29
28
  remote_run_everything/tools/sqlacodegen_go_struct.py
30
29
  remote_run_everything/vsconf/conf_txt.py
31
30
  remote_run_everything/vsconf/core.py
32
- test/test.py
33
- test/test_server.py
31
+ test/test.py
@@ -6,7 +6,9 @@ import requests
6
6
  from multiprocessing import Process
7
7
  from remote_run_everything.tools.common import Common
8
8
  from remote_run_everything.db.crude_duck import CrudeDuck
9
+ from remote_run_everything.deploy.by_http_tool import ByHttpTool
9
10
  from remote_run_everything import VsConf
11
+
10
12
  host = "http://39.96.40.177:8888/deploy"
11
13
  remote = "/data/temp"
12
14
  local = "D://wq/temp"
@@ -18,13 +20,13 @@ def push_example():
18
20
 
19
21
 
20
22
  def test():
21
- wdir="D://mygit/remote_run_everything"
22
- vs=VsConf()
23
+ wdir = "D://mygit/remote_run_everything"
24
+ vs = VsConf()
23
25
  vs.vs_rust()
24
26
 
25
27
 
26
28
  def pull_local():
27
- host = "http://127.0.0.1:9900/deploy"
29
+ host = "http://127.0.0.1:8888/deploy"
28
30
  local = "D://mypy/econ/templates"
29
31
  remote = "D://wq/temp/econ/templates"
30
32
  bh = ByHttp(host, local, remote, "D://wq/temp/testlocal.db")
@@ -38,18 +40,33 @@ def test_dec():
38
40
 
39
41
 
40
42
  def testscheme():
41
- dic=Common().read_conf()['pg']
42
- con=CrudeDuck().install_pg_ext(**{**dic,"dbname":"projects"})
43
+ dic = Common().read_conf()['pg']
44
+ con = CrudeDuck().install_pg_ext(**{**dic, "dbname": "projects"})
43
45
  dic = Common().read_conf()['mysql']['test']
44
46
  dic['dbname'] = Common().read_conf()['mysql']['md']['test']
45
- print( CrudeDuck().scheme(con, "projects", 'kv',"pg"))
47
+ print(CrudeDuck().scheme(con, "projects", 'kv', "pg"))
46
48
  con = CrudeDuck().install_mysql_ext(**dic)
47
- print( CrudeDuck().scheme(con, "md-test", 'c_dictionary',"mysql"))
48
- con=CrudeDuck().install_sql_ext("D://wq/temp/conf.db")
49
- sch = CrudeDuck().scheme(con, "conf", 'down',"sqlite3")
50
- print(sch,len(sch))
51
- CrudeDuck().delete_by_id(con,"up",0)
49
+ print(CrudeDuck().scheme(con, "md-test", 'c_dictionary', "mysql"))
50
+ con = CrudeDuck().install_sql_ext("D://wq/temp/conf.db")
51
+ sch = CrudeDuck().scheme(con, "conf", 'down', "sqlite3")
52
+ print(sch, len(sch))
53
+ CrudeDuck().delete_by_id(con, "up", 0)
54
+
55
+
56
+ def test_up():
57
+ t = ByHttpTool()
58
+ url = "http://127.0.0.1:8888/deploy"
59
+ res = t.upload_file(url, "D://wq/r1.db", "D://wq/raw.db")
60
+ print(11111, res)
61
+
62
+
63
+ def up():
64
+ host = "http://127.0.0.1:8888/deploy"
65
+ remote= "D://wq/up/temp"
66
+ local= "D://wq/temp/"
67
+ bh = ByHttp(host, local, remote, "D://wq/testlocal.db")
68
+ bh.up()
52
69
 
53
70
 
54
71
  if __name__ == '__main__':
55
- push_example()
72
+ up()
@@ -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)}
@@ -1,22 +0,0 @@
1
- from remote_run_everything.deploy.by_http_server import ByHttpServer
2
- import cherrypy, os
3
- from cherrypy.process.plugins import Daemonizer
4
- import time
5
-
6
-
7
-
8
-
9
-
10
- def cherry():
11
- cherrypy.config.update({
12
- "server.socket_port": 9900,
13
- })
14
- if os.name != "nt":
15
- d = Daemonizer(cherrypy.engine)
16
- d.subscribe()
17
-
18
- cherrypy.quickstart(ByHttpServer(), "/deploy")
19
-
20
-
21
- if __name__ == '__main__':
22
- cherry()