Esempio n. 1
0
 def test_putsecret0(self):
     # should not trigger an error, wouldn't that be nice
     y.alert_level(4)
     key = "dumdi"
     secret = "schlummbaladumdibroing"
     with y.outputCaptured() as (out, err):
         y.putsecret(key, secret, options=["zip"])
         self.assertEqual(y.getsecret(key, error_exception=False), secret)
     self.assertEqual(os.stat(default_secrets).st_mode & 0o777, 0o640)
Esempio n. 2
0
 def test_puts_main_options_1(self):
     key = "p-convention"
     value = "ITS"
     y.alert_level(y.L_ERROR)
     with y.outputAndExitCaptured() as (out, err, status):
         sys.argv = ["putsecret", "-o", "zip,b64", key, value,
                     default_secrets]
         y.secrets.putsecret_main()
     self.assertEqual(out.getvalue(), "")
     self.assertEqual(err.getvalue(), "")
     self.assertEqual(status.value, None)
Esempio n. 3
0
 def test_puts_main_options_invalid(self):
     key = "p-convention"
     value = "ITS"
     y.alert_level(y.L_ERROR)
     with y.outputAndExitCaptured() as (out, err, status):
         sys.argv = ["putsecret", "-o", "zip,x64", key, value,
                     default_secrets]
         y.secrets.putsecret_main()
     self.assertEqual(out.getvalue(), "")
     self.assertEqual(err.getvalue().split("\n")[0],
                      "putsecret: 'x64' is not a valid encoding option")
     self.assertEqual(status.value, 64)
Esempio n. 4
0
 def test_puts_main_options_b64zip(self):
     key = "p-convention"
     value = "ITS"
     y.alert_level(y.L_ERROR)
     with y.outputAndExitCaptured() as (out, err, status):
         sys.argv = ["putsecret", "-bz", key, value,
                     default_secrets]
         y.secrets.putsecret_main()
     self.assertEqual(out.getvalue(), "")
     self.assertEqual(err.getvalue(), "")
     self.assertEqual(status.value, None)
     data = self.getdata()
     self.assertEqual(data[key]["secret"], value)
     self.assertEqual(data[key]["opts"], ["zip"])
     self.assertEqual(y.getsecret(key), value)
Esempio n. 5
0
#!/usr/bin/env python3

import jpylib as y

y.alert_level(y.L_TRACE)

data = [[""] + [ "exp " + str(exp) for exp in range(8)]]
for base in range(10):
    row = ["base " + str(base)]
    for exp in range(8):
        row.append(base ** exp)
    data.append(row)

data2 = [
    ["&", "False", "True"],
    ["False", "False", "False"],
    ["True", "False", "True"],

]

t_template = r"""
.-----.
| | | |
|=====|
| | | |
|-|-+-|
| | | |
.-----.
"""

print(y.Table(data=data, align=["c*", None], template=t_template).format())
Esempio n. 6
0
#!/usr/bin/env python3
# just try out some of those functions

import time
import jpylib as y

y.alert_level(y.L_TRACE)

ovc, args = y.pgetopts({
    "v": ("verbose", y.alert_level_up, y.alert_level(), "increase verbosity"),
    "l": ("locals", locals, None, "the local vars"),
    "g": ("globals", globals, None, "the global vars"),
    "q": ("quiet", y.alert_level_zero, False, "be quiet"),
    "c": ("config_file", str, None, "configuration file path"),
    "C": ("config_item", str, [], "configuration item(s)"),
})


@y.fntrace
def fun_fun_fun(a, b, add=3):
    return (a + b) + add


@y.sanesighandler
def nap():
    """sleep a bit, so we can interrupt"""
    print("interrupt now?")
    time.sleep(3)


print(ovc.ovc_values())