Example #1
0
	def connect(self) -> fabric.Connection:
		if self.__c is None:
			pwd = self.__passwordProvider(self.__hostName, self.__userName)
			config = fabric.Config(overrides={'sudo': {'password': pwd}})
			self.__c = fabric.Connection(self.__hostName, self.__userName, self.__port, config=config, connect_kwargs={"password": pwd})

			r = self.__c.run(
				self._encodeSSHCmdLine("/bin/echo", "foo  \"  \"  bar"),
				hide=True)
			Assert.isTrue(self.__c.is_connected)
			Assert.isEqual(r.exited, 0)
			Assert.isEqual(r.stderr, "")
			Assert.isEqual(r.stdout, "foo  \"  \"  bar\n")

		return self.__c
from jk_utils.datetime import *
from jk_testing import Assert

d1 = D.now()
d2 = d1.nextDay().nextDay()
Assert.isEqual(d2 - d1, 2)
Assert.isEqual((d1.dayOfWeek + 2) % 7, d2.dayOfWeek)

d1 = D.now().startOfWeek()
d2 = d1.nextWeek()
Assert.isEqual(d2 - d1, 7)

d1 = D.now()
d2 = d1.nextWeek()
Assert.isTrue((d2 - d1) > 0)
Assert.isTrue((d2 - d1) <= 7)
Assert.isTrue(d2.dayOfWeek == 1)
Assert.isTrue((d2 - 1).dayOfWeek == 7)
Assert.isTrue(d2 >= d1)
Assert.isTrue(d1 <= d2)

d1 = D.now()
d2 = d1.nextWeek().previousWeek()
Assert.isTrue(d1 >= d2)

for d in dateRange(d1.startOfWeek(), d2.nextWeek()):
    print(d, "\t", d.toJSON())

Assert.isEqual(len(list(dateRange(d1.startOfWeek(), d2.nextWeek()))), 7)
#!/usr/bin/python3

import jk_invoke
from jk_testing import Assert

plaintext = "this is a test"
print("plaintext: " + repr(plaintext))

Assert.isFalse(jk_invoke.isPwdEncrypted(plaintext))

print("Encrypt ...")
ciphertext = jk_invoke.encryptPwd(plaintext)
print("ciphertext: " + repr(ciphertext))

Assert.isTrue(jk_invoke.isPwdEncrypted(ciphertext))

print("Decrypt ...")
plaintext2 = jk_invoke.decryptPwd(ciphertext)
print("plaintext2: " + repr(plaintext2))

Assert.isFalse(jk_invoke.isPwdEncrypted(plaintext2))

assert plaintext == plaintext2