remote-run-everything 2.0.6__py3-none-any.whl → 2.0.7__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.
@@ -1,4 +1,5 @@
1
1
  from remote_run_everything.deploy.by_http import ByHttp
2
+ from remote_run_everything.deploy.by_sftp import BySftp
2
3
 
3
4
  from remote_run_everything.db.crude_duck import CrudeDuck
4
5
  from remote_run_everything.db.crud_sqlalchemy import Crud
@@ -0,0 +1,75 @@
1
+ import os.path
2
+ from remote_run_everything.db.crud_sqlalchemy import Crud
3
+ from remote_run_everything.deploy.record_mod import Up, Down
4
+ from remote_run_everything.db.crude_duck import CrudeDuck
5
+ from remote_run_everything.deploy.by_http_tool import ByHttpTool
6
+ import paramiko
7
+ from pathlib import Path
8
+
9
+ class BySftp:
10
+ def __init__(self, host,port,user,pwd, local, remote, dbpath):
11
+ self.host=host
12
+ self.cli=self.sftp_cli(host,port,user,pwd)
13
+ self.local = local
14
+ self.remote = remote
15
+ self.dbpath = dbpath
16
+ self.t = ByHttpTool()
17
+ def sftp_cli(self,host,port,user,pwd):
18
+ ssh = paramiko.SSHClient()
19
+ ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
20
+ transport = paramiko.Transport(host, port)
21
+ transport.connect(None, user, pwd)
22
+ cli= paramiko.SFTPClient.from_transport(transport)
23
+ return cli
24
+
25
+ def up(self, disallow_keys=None):
26
+ c = Crud()
27
+ eg = c.sqlite_engine(self.dbpath)
28
+ c.create_table(eg, Up)
29
+ con = CrudeDuck().install_sql_ext(self.dbpath)
30
+ mod = Up
31
+ loc_files = self.t.all_local_path(self.local, disallow_keys)
32
+ add_l = []
33
+ for dic in loc_files:
34
+ path = dic['path']
35
+ t = dic['time']
36
+ sql = f"select * from up where path='{path}' and time='{t}' and host='{self.host}' "
37
+ res = con.sql(sql).fetchone()
38
+ if res is not None: continue
39
+
40
+ rpath = self.t.loc2remote(path, self.local, self.remote)
41
+ rpath=rpath.replace("\\","/")
42
+ lpath=path.replace("\\","/")
43
+ res=self.upload_file(rpath, lpath)
44
+ print("up==", path,res)
45
+ if res=="ok":
46
+ sql = f"delete from up where path='{path}' and host='{self.host}'"
47
+ con.execute(sql).commit()
48
+ dic['host'] = self.host
49
+ add_l.append(dic)
50
+ con.commit()
51
+ c.insert_many(eg, mod, add_l)
52
+
53
+ def mkdirs(self,fpath):
54
+ dpath = os.path.dirname(fpath)
55
+ l=dpath.split('/')
56
+ if len(l)==0:return
57
+ if l[0]=="":l[0]="/"
58
+ for i in range(len(l)+1):
59
+ if i<=1:continue
60
+ ll=l[:i]
61
+ path=os.path.join(*ll)
62
+ try:
63
+ # default mod 777
64
+ path=path.replace('\\','/')
65
+ self.cli.mkdir(path)
66
+ except Exception as e:
67
+ pass
68
+
69
+ def upload_file(self, rpath, lpath):
70
+ self.mkdirs(rpath)
71
+ try:
72
+ self.cli.put(lpath, rpath)
73
+ return "ok"
74
+ except:
75
+ return "fail"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: remote_run_everything
3
- Version: 2.0.6
3
+ Version: 2.0.7
4
4
  Summary: Deploy Tools
5
5
  Author-email: Wang Qi <wangmarkqi@gmail.com>
6
6
  License-Expression: MIT
@@ -1,4 +1,4 @@
1
- remote_run_everything/__init__.py,sha256=s0ZYAkpui5x47uOzKMkghoVW9-yW6Y4xvoEntyB0_cc,760
1
+ remote_run_everything/__init__.py,sha256=N8ReYbyAgZw7CjFrJMcC5ulqiJmchGcTEMD_nNPDfks,817
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
@@ -7,6 +7,7 @@ remote_run_everything/db/kv_store.py,sha256=Df2Lp2l5ip0YQuTdVnlQbkZT_Sz01j9D5bJ8
7
7
  remote_run_everything/deploy/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
8
  remote_run_everything/deploy/by_http.py,sha256=QWL3XqLTbp9O2WadPX59uR1fGJdgd9xzg1Pv8CuxfbQ,2661
9
9
  remote_run_everything/deploy/by_http_tool.py,sha256=H_-OvpayNVGG9e93Qnq5SCT0CsDbCEVtiA2kF2XVQ8U,3166
10
+ remote_run_everything/deploy/by_sftp.py,sha256=dGb8SmhTlFntL_wRFRSubNziSy9xrd-Uzm5AdGHgHB4,2688
10
11
  remote_run_everything/deploy/record_mod.py,sha256=29L-RTnvANpjbWRND7GGz5sdCzbz1Ba9QxdS858bdAY,725
11
12
  remote_run_everything/nosql/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
13
  remote_run_everything/nosql/no_sql.py,sha256=1-dT6LhrayQqLqZ4ES2tmWfXYCEXOnqwNzKgyXWYRG4,2343
@@ -20,8 +21,8 @@ remote_run_everything/tools/decorators.py,sha256=SIacNAs7afgkU0D09J-s-YscCVnxSG8
20
21
  remote_run_everything/tools/sqlacodegen_go_struct.py,sha256=0xWJVCjFyEF2VjC1aGo6DmIqEQQ0Q46CfBAb9FSCUuE,3237
21
22
  remote_run_everything/vsconf/conf_txt.py,sha256=nhFuKLlts-sCIBmfr0IKv1pP-qPUvQQrsRRg21q5Gd4,2418
22
23
  remote_run_everything/vsconf/core.py,sha256=HmSEzXjGPY7R64rwfAV024YxMHwmBkLin6lGace4U0M,833
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,,
24
+ remote_run_everything-2.0.7.dist-info/licenses/LICENSE,sha256=6kbiFSfobTZ7beWiKnHpN902HgBx-Jzgcme0SvKqhKY,1091
25
+ remote_run_everything-2.0.7.dist-info/METADATA,sha256=2Av2tYYjdbY14CFNFa8xGsRX0Jy_heVQRDiTUPG6ads,3121
26
+ remote_run_everything-2.0.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
27
+ remote_run_everything-2.0.7.dist-info/top_level.txt,sha256=1TUcAqPgSwiVBqUHz-1pZFXvRpr9cudEYlmfw_mztRY,22
28
+ remote_run_everything-2.0.7.dist-info/RECORD,,