Skip to content

Commit e44971d

Browse files
committed
manual tests update
1 parent 5ed74d5 commit e44971d

File tree

2 files changed

+64
-25
lines changed

2 files changed

+64
-25
lines changed

tests/manual_test.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@
1111

1212
"""
1313
c = Connection("kohn", quiet=True, local=False)
14-
print(c.os.isfile("/home/rynik/hw_config_Kohn.log"))
14+
print(c.os.path.isfile("/home/rynik/hw_config_Kohn.log"))
1515
1616
c1 = deepcopy(c)
1717
c2 = pickle.loads(pickle.dumps(c))
18-
print(c1.os.isfile("/home/rynik/hw_config_Kohn.log"))
19-
print(c2.os.isfile("/home/rynik/hw_config_Kohn.log"))
18+
print(c1.os.path.isfile("/home/rynik/hw_config_Kohn.log"))
19+
print(c2.os.path.isfile("/home/rynik/hw_config_Kohn.log"))
2020
2121
print(id(c), id(c1), id(c2))
2222
2323
mc = MultiConnection(["kohn"], quiet=True)
24-
for out in mc.os.isfile("/home/rynik/hw_config_Kohn.log"):
24+
for out in mc.os.path.isfile("/home/rynik/hw_config_Kohn.log"):
2525
print(out)
2626
mc.keys()
2727
mc.values()
@@ -40,28 +40,28 @@
4040
4141
4242
with MultiConnection(["kohn"], quiet=True) as mc:
43-
for out in mc.os.isfile("/home/rynik/hw_config_Kohn.log"):
43+
for out in mc.os.path.isfile("/home/rynik/hw_config_Kohn.log"):
4444
print(out)
4545
4646
mcl = MultiConnection.from_dict(a, quiet=True)
4747
k = mcl["kohn"]
4848
print("id", id(MultiConnection))
49-
print(k.os.isfile)
50-
print(k.os.isfile("/home/rynik/hw_config_Kohn.log"))
51-
#print(mcl["fock"].os.isfile("/home/rynik/hw_config_Kohn.log"))
49+
print(k.os.path.isfile)
50+
print(k.os.path.isfile("/home/rynik/hw_config_Kohn.log"))
51+
#print(mcl["fock"].os.path.isfile("/home/rynik/hw_config_Kohn.log"))
5252
print("---------------")
53-
for o in mcl.os.isfile("/home/rynik/hw_config_Kohn.log"):
53+
for o in mcl.os.path.isfile("/home/rynik/hw_config_Kohn.log"):
5454
print(o)
5555
5656
5757
print("..............................................................")
5858
with Connection("kohn", quiet=True, local=False) as c:
59-
print(c.os.isfile("/home/rynik/hw_config_Kohn.log"))
59+
print(c.os.path.isfile("/home/rynik/hw_config_Kohn.log"))
6060
6161
con = str(c)
6262
6363
c = Connection.from_str(con, quiet=True)
64-
print(c.os.isfile("/home/rynik/hw_config_Kohn.log"))
64+
print(c.os.path.isfile("/home/rynik/hw_config_Kohn.log"))
6565
6666
A = TypeVar("A")
6767
B = TypeVar("B")

tests/new_test.py

Lines changed: 53 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,50 @@
1+
from ssh_utilities.remote.remote import SSHConnection
12
from typing import Any
3+
from ssh_utilities import Connection
4+
"""
25
3-
6+
with Connection("kohn") as c:
7+
c: SSHConnection
8+
for d in c.os.scandir("/home/rynik"):
9+
print(d.name, d.is_dir())
10+
# !!! Function and context manager at the same time !!!
411
class A:
512
6-
def ahoj(self):
7-
print("ahoj")
13+
def __init__(self) -> None:
14+
self.i = 0
815
916
def __enter__(self):
10-
print("enter")
1117
return self
1218
1319
def __exit__(self, *args):
20+
self.close()
21+
22+
def __iter__(self):
23+
return self
24+
25+
def __next__(self):
26+
if self.i < 10:
27+
try:
28+
return self.i
29+
finally:
30+
self.i += 1
31+
else:
32+
raise StopIteration
33+
34+
def close(self):
1435
pass
1536
1637
38+
with A() as b:
39+
for i in b:
40+
print(i)
41+
print("----------------------------")
42+
43+
b = A()
44+
for i in b:
45+
print(i)
46+
#print(b.attr)
47+
1748
class C:
1849
1950
def __new__(cls) -> Any:
@@ -27,17 +58,25 @@ def __new__(cls) -> Any:
2758
with C() as c:
2859
c.ahoj()
2960
61+
"""
3062

3163
from ssh_utilities import Connection
3264

33-
c = Connection("kohn")
34-
print(c.address)
35-
c.close()
36-
3765
with Connection("kohn") as c:
38-
print(c.address)
39-
40-
41-
c = Connection["kohn"]
42-
print(c.address)
43-
c.close()
66+
#p = c.pathlib.Path("/home/rynik/test")
67+
#p.mkdir()
68+
#p.rmdir()
69+
70+
#p = c.pathlib.Path("/home/rynik/.bashrc")
71+
#print(p.is_dir())
72+
#print(p.read_text())
73+
#print(p.read_bytes())
74+
75+
p = c.pathlib.Path("/home/rynik/dpmd/selective_metad1/gen44")
76+
print(c.os.chmod(p, 111))
77+
print(c.sftp.normalize("/home/rynik/dpmd"))
78+
#print(p)
79+
#for pp in p.rglob("*"):
80+
# print(pp, type(pp))
81+
#for root, dirs, files in c.os.walk(p):
82+
# print(root, dirs, files)

0 commit comments

Comments
 (0)