Esempio n. 1
0
def save(obj, path):
    # NOTE: even for OrderedDict yaml will sort keys on dump!
    if '-' == path:
        yaml.safe_dump(obj, stream=sys.stdout)
    else:
        with open(expand_pj(path), 'w') as f:
            yaml.safe_dump(obj, stream=f)
Esempio n. 2
0
 def _createTray(self):
     from PyQt5.QtWidgets import QSystemTrayIcon
     from PyQt5.QtGui import QIcon
     from piony.common import expand_pj
     tray = QSystemTrayIcon()
     tray.setIcon(QIcon(expand_pj(":/res/tray-normal.png")))
     tray.show()
     return tray
Esempio n. 3
0
def parse(entry):
    if not entry:
        obj = None
    elif '-' == entry:
        obj = yaml.safe_load(sys.stdin)  # entry = sys.stdin.read()

    elif os.path.isfile(expand_pj(entry)):            # && os.path.isabs(PATH)
        with open(expand_pj(entry), 'r') as f:
            obj = yaml.safe_load(f)      # entry = f.read()
    else:
        obj = yaml.safe_load(entry)

    if obj and isinstance(obj, str):
        raise InputError(obj, 'Seems like non-existent path: {}' .format(obj))
    elif obj and not isinstance(obj, (list, OrderedDict)):
        raise InputError(obj, 'Loaded not allowed obj type: {}' .format(type(obj)))
    return obj
Esempio n. 4
0
 def test_pj(self):
     assert 'some/path' == expand_pj(':/path', 'some')
     assert '/path' == expand_pj('/path')
Esempio n. 5
0
 def test_non(self):
     assert None == expand_pj(None)
     assert ':path' == expand_pj(':path')
Esempio n. 6
0
#!/usr/bin/env python3
# vim: fileencoding=utf-8

import sys
import yaml
import logging.config
from piony.common import expand_pj

G_LOG_PATH = ':/cfgs/log.yml'
with open(expand_pj(G_LOG_PATH), 'r') as f:
    logging.config.dictConfig(yaml.safe_load(f.read()))


if __name__ == '__main__':

    ## Send args to listener and close
    from piony.system.client import Client
    client = Client()
    client.connect()
    if client.socket.waitForConnected(2000):
        # DEV: send also [0] element -- to use client pwd for pathes in cmdline
        client.send(sys.argv[1:])
        client.socket.close()

    else:
        from signal import signal, SIGINT, SIG_DFL
        ## Close on 'Ctrl-C' system signal.
        ## WARNING: No cleanup possible (can't implement because of Qt).
        signal(SIGINT, SIG_DFL)

        import inject
Esempio n. 7
0
#!/usr/bin/env python3
# vim: fileencoding=utf-8

import sys
import yaml
import logging.config
from piony.common import expand_pj

G_LOG_PATH = ':/cfgs/log.yml'
with open(expand_pj(G_LOG_PATH), 'r') as f:
    logging.config.dictConfig(yaml.safe_load(f.read()))

if __name__ == '__main__':

    ## Send args to listener and close
    from piony.system.client import Client
    client = Client()
    client.connect()
    if client.socket.waitForConnected(2000):
        # DEV: send also [0] element -- to use client pwd for pathes in cmdline
        client.send(sys.argv[1:])
        client.socket.close()

    else:
        from signal import signal, SIGINT, SIG_DFL
        ## Close on 'Ctrl-C' system signal.
        ## WARNING: No cleanup possible (can't implement because of Qt).
        signal(SIGINT, SIG_DFL)

        import inject
        from piony.gstate import GState