How to use the sarge.Feeder function in sarge

To help you get started, we’ve selected a few sarge examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ThiefMaster / fsnotifier-remote / fsnotifier.py View on Github external
exe_dir = os.path.dirname(os.path.realpath(sys.executable if hasattr(sys, 'frozen') else sys.argv[0]))
    config_file = os.path.join(exe_dir, 'fsnotifier.yaml')

    try:
        with open(config_file) as f:
            config = yaml.load(f)
    except FileNotFoundError:
        print('Config file not found: {}'.format(config_file))
        sys.exit(1)

    logfile = open(config['log']['file'] if config['log']['enabled'] else os.devnull, 'w')
    config['reverse_mapping'] = {v: '{}:'.format(k) for k, v in config['mapping'].items()}

    # Local notifier
    local_stdin = sarge.Feeder()
    local_watcher = sarge.run(config['fsnotifier']['local'], stdout=sarge.Capture(), input=local_stdin, async_=True)
    local_monitor = LocalMonitorThread(daemon=True)

    # Remote notifier
    ssh_conn = paramiko.SSHClient()
    ssh_conn.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    ssh_conn.connect(config['ssh']['host'], username=config['ssh']['user'], allow_agent=True)
    ssh_stdin, ssh_stdout, _ = ssh_conn.exec_command(config['fsnotifier']['remote'])
    remote_monitor = RemoteMonitorThread(daemon=True)

    local_monitor.start()
    remote_monitor.start()

    receiving_roots = False
    new_roots = []
    while True:

sarge

A wrapper for subprocess which provides command pipeline functionality.

BSD-2-Clause
Latest version published 2 years ago

Package Health Score

49 / 100
Full package analysis