def upload(project="default"): files = os.listdir(settings.export_path) if len(files) == 0: print '---Non file going to upload.' return print 'SSH BEGIN' ssh = SSH(settings.Applications[project]['server_ip'], settings.Applications[project]['server_name'], settings.Applications[project]['server_passwd']) ssh.connect() ssh.execute("rm", settings.server_data_path + "/*") scp = SCPClient(ssh.ssh.get_transport()) scp.put(settings.export_path, settings.server_path, recursive=True) ssh.close()
stdin, stdout, stderr = self.ssh.exec_command(command) out = stdout.readlines() for line in out: print line return out def close(self): print '%s\t SSH CLOSE\n' % self._ip try: self.ssh.close() self.ssh = None except Exception, e: print e def __del__(self): if self.ssh: self.close() if __name__ == '__main__': from publisher.scp import SCPClient print 'begin' ssh = SSH('solidai.net', 'solidai', '1234567890)(*&^%$#@!') ssh.connect() scp = SCPClient(ssh.ssh.get_transport()) scp.put('/home/kong/project/publisher/data', 'publisher/data', recursive=True) # ssh.execute("cal") # ssh.execute("touch hello.txt") ssh.close()