def play():
    """
    Start up playback_starter in main Python thread
    """
    LOG.debug('Full sys.sys.argv received: %s', sys.argv)
    # Put the request into the 'queue'
    if not sys.argv[2]:
        # Browsing to a tv show from a tv show info dialog - picked up
        # by kodimonitor.py and its method OnAdd
        xbmcplugin.setResolvedUrl(HANDLE, False, xbmcgui.ListItem())
        return
    else:
        request = '%s&handle=%s' % (unicode_paths.decode(sys.argv[2]), HANDLE)
        if b'resume:true' in sys.argv:
            request += '&resume=1'
        elif b'resume:false' in sys.argv:
            request += '&resume=0'
        transfer.plex_command('PLAY-%s' % request)
    if HANDLE == -1:
        # Handle -1 received, not waiting for main thread
        return
    # Wait for the result
    result = transfer.wait_for_transfer(source='main')
    if result is True:
        xbmcplugin.setResolvedUrl(HANDLE, False, xbmcgui.ListItem())
        # Tell main thread that we're done
        transfer.send(True, target='main')
    else:
        xbmcplugin.setResolvedUrl(HANDLE, True, result)
Esempio n. 2
0
def deploy(ssh):
    sys.stdout.write("Deploying pyscp on remote\n")

    stdin, stdout, stderr = ssh.exec_command("uname")
    while not stdout.channel.exit_status_ready():
        time.sleep(5.0 / 60.0)  # 5s
    if stdout.channel.recv_exit_status() != 0:
        sys.stderr.write(stderr.read(-1))
        return None
    # TODO: add MacOS and other Unix systems
    if "Linux" not in stdout.read(-1):
        sys.stderr.write("Deployment is supported only on Linux\n")
        return None

    tf = tempfile.NamedTemporaryFile(mode="wb", suffix=".zip", delete=True)
    pzf = zipfile.PyZipFile(tf, mode="w")
    pzf.writepy(os.path.dirname(sys.argv[0]))
    pzf.close()

    remote_tempfile = _prepare_remote_dep_file(ssh)
    if not remote_tempfile:
        return None

    stdin, stdout, stderr = ssh.exec_command("scp -t '{}'".format(remote_tempfile))

    ret = tfr.send(stdin, stdout, sys.stderr, sys.stdout, [tf.name], False, False)
    if ret == error.E_OK or ret == error.E_END:
        return remote_tempfile
    else:
        sys.stderr.write(stderr.readline())
        return None
Esempio n. 3
0
def _local_send(ssh, paths, sink_path, rec, preserve, check_hash):
    try:
        stdin, stdout, stderr = _open_channels(ssh, sink_path,
                                               False, rec, preserve, check_hash)
    except Exception as ex:
        sys.stderr.write(str(ex) + '\n')
        return 1

    ret = tfr.send(stdin, stdout, sys.stderr, sys.stdout, paths, preserve, check_hash)
    if ret == error.E_OK or ret == error.E_END:
        return 0
    else:
        sys.stderr.write(stderr.readline())
        return 1
Esempio n. 4
0
File: main.py Progetto: Valink16/SWT
import myLib
import transfer

myLib.log("Welcome to SWT")

r = input("(S)end or (R)eceive ?: ")

if r.upper() == "S":
    transfer.send()
elif r.upper() == "R":
    transfer.receive(1041, 150)
else:
    myLib.log("Choose \"S\" or \"R\"")
Esempio n. 5
0
def _remote_send(paths, rec, preserve, check_hash):
    ret = tfr.send(sys.stdout, sys.stdin, sys.stderr, None, paths, preserve, check_hash)
    if ret == error.E_OK or ret == error.E_EN:
        return 0
    else:
        return 1