示例#1
0
def connect_ssh(host, username, password, port):
    '''
    Se conecta a un servidor via ssh y devuelve un objeto cliente.
    '''
    client = paramiko.SSHClient()
    client.load_system_host_keys()
    client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    client.connect(host, port, username, password)
    return client
示例#2
0
def Get_data( filename):
	
	client = paramiko.SSHClient()
	client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
	client.connect('10.53.214.10', username='******', password='******')
	sftp = client.open_sftp()
	rf = sftp.open(filename)
	line= rf.read()
	l=line.strip()
	#print l
	return l	
示例#3
0
def transmit(filepath, server='10.0.2.13'):
    '''Windows version'''
    client = socket.socket()
    # Open a port of our choosing
    try:
        client.connect((server, 10000))
    except socket.error:
        print("The connection was refused.")
        return

    with open(filepath, 'rb') as f:
        win32file.TransmitFile(client, win32file._get_osfhandle(f.fileno()), 0,
                               0, None, 0, b'', b'')

    print(f'\nFile {filepath} was sent successfully.')
示例#4
0
    file_path, local, ip, username, key, file, level, token, bookWS, bookSort, movieWS, movieSort = check_settings(
        file_path, local, ip, username, key, file, level, token, bookWS, bookSort, movieWS, movieSort, gameWS, 
        gameSort, True)
    my_logger.config_root_logger(file_path, level)

my_logger.clean_up_logs(file_path)
my_logger.start_thread_logging(file_path)
if not local:
    try:
        # If in remote mode, SSH into server
        logging.debug("Attempting to SSH into %s", ip)
        print("Connecting to", ip)
        client = paramiko.SSHClient()
        client.load_system_host_keys()
        client.set_missing_host_key_policy(paramiko.WarningPolicy)
        client.connect(ip, port=22, username=username, password="", pkey=None, key_filename=key)
    except Exception as inst:
        # If SSH fails for any reason fall back to local mode
        print("Unable to connect to host.")
        logging.critical("Failed to connect to %s using %s and %s error was:\n%s", ip, username, key, inst)
        print(inst)
        logging.critical("Falling back to local mode")
        print("Falling back to local mode\a")
        client = None
        local = True
else:
    # Set SSH client to none for local mode
    logging.debug("Skipping connecting to remote host")
    client = None
try:
    if token:
示例#5
0
            position[1] = data[0]
        if addr.startswith('/-stat/userpar/') and addr.endswith('/value') \
                and data and data[0]:
            button = int(addr[15:17])
            if button >= 21 and button <= 24:
                song_index = button - 21
                reset_track_buttons(client, except_track=song_index)
                print 'selecting song ', song_index

    print 'Starting OSC server'
    server = OSC.OSCServer(("", server_udp_port))
    server.addMsgHandler("default", msgPrinter_handler)

    print 'Starting OSC client'
    client = OSC.OSCClient(server=server)
    client.connect((x32_address, 10023))

    reset_track_buttons(client)
    # Turn on the button for track 0.
    client.send(OSC.OSCMessage('/-stat/userpar/21/value', [127]))

    # Request the current minutes and seconds values.
    client.send(OSC.OSCMessage('/-stat/userpar/33/value'))
    client.send(OSC.OSCMessage('/-stat/userpar/34/value'))

    print 'Staring change notification thread'
    thread = threading.Thread(target=request_x32_to_send_change_notifications,
        kwargs = {"client": client})
    thread.setDaemon(True)
    thread.start()
    print 'Running'