# -*- coding:utf-8 -*-
list1=[]
list2=[]
list3 = []
list4 = []
while True:
inputs = raw_input("按 a 查询节点: 按 b 添加节点: 按c删除节点:")
if inputs =="a":
while True:
inputs1 = raw_input("请输入要查询的节点名称: 按b返回上一级: 按q退出")
if inputs1 =="b":
break
elif inputs1 =="q":
exit()
elif inputs1 =="www.oldboy.org":
f = open("haproxy")
ha_list = []
for i in f:
ha_list.append(i.strip())
b = int(ha_list.index("backend www.oldboy.org"))+1
while True:
title = "\033[32;1m服务器节点列表\033[0m"
print title.center(60, "*")
for i in ha_list[b:]:
print i
print "\033[32;1mend\033[0m".center(50,"*")
choice = raw_input("按b返回上一级: 按q退出程序:")
if choice =="b":
break
elif choice =="q":
exit()
else:
print "输入错误,没有该节点,请重新输入节点名称:"
elif inputs =="b":
data = raw_input("请输入要增加的节点:")
c = eval(data)
a = c["record"]
print a
for key in a.item:
print key , a.get(key)
#list.append(key)
#list2.append(a.get(key))
print list ,list2
# list.insert(2, list2[2])
# list.insert(1, str(list2[1]))
# list.insert(0, str(list2[0]))
# list.reverse()
# # print list
# strs = ' '.join(list)
# print strs
# f = open("test.txt", "a+")
# f.write(strs)
# f.close()

{'backend':'www.oldboy.org','record':{'server':'10.10.99.3','weight':20,'maxconn':30}}

data = raw_input("input:")
a = eval(data)
# print a["backend"]
# print a["record"]
list = []
list2= []
a = {'maxconn': 30, 'weight': 20, 'server': '100.2.1.1'}
for key in a.iterkeys():
#print key , a.get(key)
list.append(key)
list2.append(a.get(key))
#print list ,list2
list.insert(2,list2[2])
list.insert(1,str(list2[1]))
list.insert(0,str(list2[0]))
list.reverse()
#print list
strs = ' '.join(list)
print strs
f = open("test.txt","a+")
f.write(strs)
f.close()
 # -*- coding:utf-8 -*-
import paramiko,os,sys,time
#-----------------------更新svn-------------------------------------------------
msg = "正在更新本地svn"
msg1 = "更新完成"
print msg.center(50,"*")
os.system("cd /data/yunweisvn/sh/clearscript && svn update")
print msg1.center(50,"*")
#--------------------拷贝清库脚本到目标机器------------------------------------- host_name = sys.argv[1]
password = "B^Dc%4LSBvhZZK3B"
port = 22
local_sunif = "/data/yunweisvn/sh/clearscript/sunif/cleartable.sql"
remote_sunif = "/data/cleardb/sunif/initscrpit/cleartable.sql" def ssh_scp_put(ip,port,user,password,local_file,remote_file):
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(ip, 22, 'root', password)
a = ssh.exec_command('date')
stdin, stdout, stderr = a
print stdout.read()
sftp = paramiko.SFTPClient.from_transport(ssh.get_transport())
sftp = ssh.open_sftp()
sftp.put(local_file, remote_file)
if host_name == "s3":
ip = "10.10.123.96"
ssh_scp_put(ip,port,"root",password,local_sunif,remote_sunif)

2

 # -*- coding:utf-8 -*-
import time,os shop_car2 =[]
user_list = []
count = 0
user = "liruixin"
password = ""
raw_user = raw_input("username:")
f=open("user.txt",'a+')
lines=[]
for lines in f.readlines():
lines=lines.replace("\n","").split(",")
f.close()
for i in lines:
if i == raw_user:
print "this user is locked, please request to root"
exit()
else:
pass
while count <3:
if raw_user == user:
raw_password = raw_input("password:")
count = count+1
if count == 3:
user_list.append(raw_user)
user = open('user.txt','a')
for raw_user in user_list:
user.write(raw_user + ',')
user.close()
else:
pass
if raw_password == password:
print "success"
a = time.localtime()
b = time.strftime("%Y-%m-%d %H:%M:%S", a)
title = "welcome to shopping"
print b.center(40, "*")
print title.center(40, "*")
shop_car = []
goods_list = [
["iphone 7", 5888],
["coffe", 30],
["computer", 3999],
["mac pro", 12000]
]
filename = r'salary.txt'
if os.path.exists(filename):
temp = open("salary.txt", "r")
for i in temp:
salary = i
print "您的卡上余额为", salary
else:
salary = raw_input("请输入充值金额:") if salary.isdigit():
salary = int(salary)
while True:
print "******* good list **********"
for i in enumerate(goods_list):
print i[0] + 1, i[1][0], i[1][1]
choice = raw_input("choice goods __ quit to exit:")
if choice.isdigit():
choice = int(choice)
if choice <= 4 and choice >= 1:
if salary >= goods_list[choice - 1][1]:
salary = salary - goods_list[choice - 1][1]
price = (goods_list[choice - 1][1])
item = (goods_list[choice - 1][0])
print "你购买了 [\033[32;1m%s\033[0m] 花费了 [\033[31;1m%d\033[0m] , 你的余额为 [\033[31;1m%d\033[0m]" % (
item, price, salary)
shop_car.append(goods_list[choice - 1])
else:
print "你的余额不足,请选择其他商品"
continue
elif choice == "quit":
print "你购买的商品如下"
print shop_car
for i in shop_car: print a
# for i in a:
# print i, shop_car.count(i) print "你的余额为\033[31;1m%d\033[0m" % salary
salary_file = open("salary.txt", "w")
salary_file.write("%d" % salary)
salary_file.close()
exit() else:
print "没有该商品,请重新输入"
continue
else:
print "this password error"
else:
print "no this user"
exit()

3333

 # -*- coding:utf-8 -*-
import os,sys,paramiko,time
#*******判断所有测试环境是否有某个文件***********
s7 = "10.10.123.96"
s3 = "10.10.39.70"
host_dic = {"10.10.154.77":"s1",
"10.10.83.96":"s2",
"10.10.39.70":"s3",
"10.10.46.120":"s4",
"10.10.15.128":"s5",
"10.10.84.48":"s6",
"10.10.123.96":"s7",
"10.10.105.91":"qa1",
"10.10.92.48":"qa2",
"10.10.50.30":"qa3",
"10.10.40.136":"qa4",
"10.10.189.139":"qa5"
}
not_exist ={}
port =22
user = "root"
passwd = "B^Dc%4LSBvhZZK3B"
print "\033[32;1m****使用说明:该脚本可以判断文件,不能判断目录。****\033[0m"
while True:
choice = raw_input("请输入要查询远端服务器上文件的绝对路径:")
v = "ls"
c = v + " " +choice
print c
for i in host_dic:
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(i,port,user,passwd)
stdin, stdout, stderr = ssh.exec_command(c)
result = stdout.read()
#print result
if result != "":
print host_dic.get(i),"\033[31;1m上存在该文件\033[0m" #print host_dic.get(i),"\033[33;1m上存在该文件\033[0m"
ssh.close()
#print not_exist
# choice1 = raw_input("按任意键继续查询,按t拷贝本地一个文件到不存在该文件的机器上,按q退出:")
# if choice1 =="q":
# print "感谢使用,再见"
# print exit()
# elif choice == "t":
# local_file = raw_input("请输入要同步的文件的绝对路径:")
# remote_file = raw_input("请输入要复制到远端机器的绝对路径:")
# for j in not_exist:
# scp = paramiko.SSHClient()
# scp.set_missing_host_key_policy(paramiko.AutoAddPolicy())
# scp.connect(j,port,user,passwd)
# sftp = paramiko.SFTPClient.from_transport(scp.get_transport())
# sftp = scp.open_sftp()
# sftp.put(local_file,remote_file)
# print "已复制到",j
#
#
# # def ssh_scp_get(ip, port, user, password, remote_file, local_file):
# # ssh = paramiko.SSHClient()
# # ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
# # ssh.connect(ip, 22, 'root', password)
# # a = ssh.exec_command('date')
# # stdin, stdout, stderr = a
# # print stdout.read()
# # sftp = paramiko.SFTPClient.from_transport(ssh.get_transport())
# # sftp = ssh.open_sftp()
# # sftp.get(remote_file, local_file)
#
#
#
#
#

sql

 # -*- coding:utf-8 -*-
import paramiko,os,sys,time,json def ssh_scp_put(ip,port,user,password,local_file,remote_file):
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(ip, 22, 'root', password)
a = ssh.exec_command('date')
stdin, stdout, stderr = a
print stdout.read()
sftp = paramiko.SFTPClient.from_transport(ssh.get_transport())
sftp = ssh.open_sftp()
sftp.put(local_file, remote_file) def ssh_scp_get(ip, port, user, password, remote_file, local_file):
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(ip, 22, 'root', password)
a = ssh.exec_command('date')
stdin, stdout, stderr = a
print stdout.read()
sftp = paramiko.SFTPClient.from_transport(ssh.get_transport())
sftp = ssh.open_sftp()
sftp.get(remote_file, local_file) def ssh_cmd(ip,port,cmd,user,passwd):
result = ""
try:
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(ip,port,user,passwd)
stdin, stdout, stderr = ssh.exec_command(cmd)
result = stdout.read()
print result
ssh.close()
except:
print "ssh_cmd err."
return result host_dic = {
# "10.10.83.96":"s2",
# "10.10.39.70":"s3",
# "10.10.46.120":"s4",
# "10.10.15.128":"s5",
# "10.10.84.48":"s6",
"s7":"10.10.123.96",
# "10.10.105.91":"qa1",
# "10.10.92.48":"qa2",
# "10.10.50.30":"qa3",
# "10.10.40.136":"qa4",
# "10.10.189.139":"qa5"
} db_info = {
"sunif":'''sunif/"sun123jfdbc$"''',
"sunfcbp":'''sunfcbp/"fcbp2016$a"''',
"ltts":'''cbmain_user/"cbmuser123~"''',
"sump":'''sump/"smp123~ab"''' } port = 22
user = "root"
user1 = "oracle"
pwd = "B^Dc%4LSBvhZZK3B"
pwd1= "Qaoracle"
#cmd = "sh /mnt/clear.sh %s"
choice_host = raw_input("请输入要执行sql的机器名称:")
local_file = raw_input("请输入要执行sql文件的绝对路径:")
remote_file = "/mnt/tmp.sql"
remote_file2 = "/mnt/sql-log.txt"
local_file2 = "C:/Users/Administrator/PycharmProjects/learn/work/tmp-log.txt"
#复制本地的sql文件到指定机器
ssh_scp_put(host_dic[choice_host],port,user,pwd,local_file,remote_file)
print "\033[32;1m已复制到 %s\033[0m"%host_dic.get(choice_host)
choice_user = raw_input("请输入要登录的用户:")
if choice_user in db_info:
a = db_info.get(choice_user)
cmd = "sh /mnt/clear.sh %s"%a
# #执行这个sql文件
ssh_cmd(host_dic[choice_host],port,cmd,user1,pwd1)
# #把日志传回
ssh_scp_get(host_dic[choice_host],port,user,pwd,remote_file2,local_file2)

作业加强版

 import  os
def open_file(filename):
with open(filename,"r",encoding="utf-8") as r_file:
tag = False
for r_line in r_file:
tmp = r_line.strip()
tmp2 = tmp.split
print (tmp2)
return open_file def fetch():
pass def add():
pass def remove():
pass def update():
pass if __name__ == '__main__':
msg='''\033[32;1m
1:查询
2:添加
3:删除
4:修改
5:退出
\033[0m'''
menu_dic={
'':"fetch",
'':"add",
'':"remove",
'':"update",
'':exit,
}
print("\033[32;1m***********************欢迎来到员工管理系统**************************\033[0m")
while True:
print(msg)
choice = input("操作>>:").strip()
if len(choice) == 0 or choice not in menu_dic:
continue
elif choice =="":exit()
elif choice =="":
data = input("请输入查询语句>>:")
if "where age" in data:
f = fetch()
print (f[1])
 import  paramiko
import os user = "root"
ips = "10.10.123.96"
password = "B^Dc%4LSBvhZZK3B"
port = 22 class Tools(object):
'''远程执行命令,文件上传,文件下载'''
def __init__(self,user,password,port,ips):
self.user = user
self.password = password
self.port = port
self.ip = ips def connect(self):
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(self.ip, self.port, self.user, self.password) def cmd(self):
cmd = input("请输入要执行的命令:>>")
ssh.exec_command(cmd)
#result = stdout.read() #return result def put(self):
'''上传'''
local_file_abs = input("本地文件的绝对路径:>>")
remote_file_abs = input("远程文件的绝对路径:>>")
transport = paramiko.Transport(self.ip,self.port)
transport.connect(self.user,self.password)
sftp = paramiko.SFTPClient.from_transport(transport)
sftp.put(local_file_abs,remote_file_abs)
transport.close()
def get(self):
'''下载'''
remote_file_abs = input("远程文件的绝对路径:>>")
local_file_abs = input("本地文件的绝对路径:>>")
transport = paramiko.Transport(self.ip,self.port)
transport.connect(self.user, self.password)
sftp = paramiko.SFTPClient.from_transport(transport)
sftp.get(remote_file_abs,local_file_abs)
transport.close()
obj = Tools(user,password,port,ips) if __name__ == "__main__":
msg = '''
执行命令 >>输入cmd
上传文件 >>输入put
下载文件 >>输入get
退出 >>输入q
'''
while True:
print(msg)
inp = input("请输入:>>")
if len(inp) == 0:continue
elif inp == "q":exit()
if hasattr(obj,inp):
getattr(obj,inp)()
else:
print("输入有误,请重新输入")
continue

FTPclient

 import optparse
import socket
import json STATUS_CODE = {
250 : "Invalid cmd format, e.g: {'action':'get','filename':'test.py','size':344}",
251 : "Invalid cmd ",
252 : "Invalid auth data",
253 : "Wrong username or password",
254 : "Passed authentication",
}
class FTPClient(object):
def __init__(self):
parser = optparse.OptionParser()
parser.add_option("-s","--server",dest="server",help="ftp server ip address")
parser.add_option("-P","--port",dest = "port" ,help="port")
parser.add_option("-u","--username", dest="username",help = "username")
parser.add_option("-p","--password",dest="password",help="password")
self.option,self.args = parser.parse_args()
self.verify_args(self.option,self.args)
self.make_connection()
def make_connection(self):
self.sock = socket.socket()
self.sock.connect((self.option.server,int(self.option.port))) def verify_args(self,options,args):
if options.username is not None and options.password is not None:
pass
elif options.username is None and options.password is None:
pass
else:
exit("Err: username and password must be provided together..") if int(options.port) > 0 and int(options.port) < 65535:
return True
else:
exit("Err:host port must in 0-65535") def authenticate(self):
if self.option.username:
print(self.option.username,self.option.password)
return self.get_auth_result(self.option.username,self.option.password)
else:
retry_count = 0
while retry_count <3:
username = input("username:").strip()
password = input("password:").strip()
return self.get_auth_result(username,password) def get_auth_result(self,username,password):
data = {"action":"auth",
"username":username,
"password":password}
self.sock.send((json.dumps(data)).encode())
print("信息已发送,等待返回")
response = self.get_response()
print("recv:",response)
if response.get("status_code") == 254:
print("Passed authentication!")
self.user = username
return True
else:
print(response.get("status_msg")) def get_response(self):
data = self.sock.recv(1024)
print("server res",data)
data = json.loads(data.decode())
return data
def _get(self):
pass def _put(self,cmd_list):
file_name = cmd_list[1] def interactive(self):
if self.authenticate():
print("---start interactive with %s---" % self.user)
while True:
choice = input("[%s]:"%self.user).strip()
if len(choice) == 0:continue
cmd_list = choice.split()
if hasattr(self,"_%s"%cmd_list[0]):
func = getattr(self,"_%s"%cmd_list[0])
func(cmd_list)
else:
print("Invalid cmd") if __name__ =="__main__":
ftp = FTPClient()
ftp.interactive()

FTPserver

 import socketserver
import configparser
from conf import settings
import os
import hashlib STATUS_CODE = {
250 : "Invalid cmd format, e.g: {'action':'get','filename':'test.py','size':344}",
251 : "Invalid cmd ",
252 : "Invalid auth data",
253 : "Wrong username or password",
254 : "Passed authentication",
255 : "Filename doesn't provided",
256 : "File doesn't exist on server",
257 : "ready to send file",
258 : "md5 verification",
259:"Authentication failure"
} import json
class FTPHandler(socketserver.BaseRequestHandler): def handle(self):
while True:
self.data = self.request.recv(1024).strip()
print("recv:",self.data)
print("client addr:-->",self.client_address[0])
print(self.data)
if not self.data:
print("client closed......")
break
data = json.loads(self.data.decode())
if data.get('action') is not None:
print("---->",hasattr(self,"_auth"))
if hasattr(self,"_%s"%data.get("action")):
func = getattr(self,"_%s"%data.get("action"))
func(data)
else:
print("Invalid cmd format, e.g: {'action':'get','filename':'test.py','size':344}")
self.send_response(250)
else:
print("Invalid cmd")
self.send_response(251) def send_response(self,status_code,data = None):
response = {"status_code":status_code,"status_msg":STATUS_CODE[status_code]}
if data:
response.update(data)
self.request.send(json.dumps(response).encode()) def _auth(self,*args,**kwargs):
data = args[0]
user = self.authenticate(data.get("username"),data.get("password"))
if user is None:
print("Authentication failure")
self.send_response(259)
else:
print("%s Passed authentication"%user["User"])
self.user = user
self.send_response(254) def authenticate(self,username,password):
config = configparser.ConfigParser()
config.read(settings.ACCOUNT_FILE)
if username in config.sections():
if password == config[username]["Password"]:
config[username]["User"] = username
return config[username] def _get(self):
pass def _put(self):
pass def _ls(self):
pass

ftpcli

 import optparse
import socket
import json
import hashlib STATUS_CODE = {
250 : "Invalid cmd format, e.g: {'action':'get','filename':'test.py','size':344}",
251 : "Invalid cmd ",
252 : "Invalid auth data",
253 : "Wrong username or password",
254 : "Passed authentication",
}
class FTPClient(object):
def __init__(self):
parser = optparse.OptionParser()
parser.add_option("-s","--server",dest="server",help="ftp server ip address")
parser.add_option("-P","--port",dest = "port" ,help="port")
parser.add_option("-u","--username", dest="username",help = "username")
parser.add_option("-p","--password",dest="password",help="password")
self.option,self.args = parser.parse_args()
print(self.option,self.args)
self.verify_args(self.option,self.args)
self.make_connection()
def make_connection(self):
self.sock = socket.socket()
self.sock.connect((self.option.server,int(self.option.port))) def verify_args(self,options,args):
if options.username is not None and options.password is not None:
pass
elif options.username is None and options.password is None:
pass
else:
exit("Err: username and password must be provided together..") if int(options.port) > 0 and int(options.port) < 65535:
return True
else:
exit("Err:host port must in 0-65535") def authenticate(self):
if self.option.username:
print(self.option.username,self.option.password)
return self.get_auth_result(self.option.username,self.option.password)
else:
retry_count = 0
while retry_count <3:
username = input("username:").strip()
password = input("password:").strip()
return self.get_auth_result(username,password) def get_auth_result(self,username,password):
data = {"action":"auth",
"username":username,
"password":password}
self.sock.send((json.dumps(data)).encode())
print("信息已发送,等待返回")
response = self.get_response()
print("recv:",response)
if response.get("status_code") == 254:
print("Passed authentication!")
self.user = username
return True
else:
print(response.get("status_msg")) def get_response(self):
data = self.sock.recv(1024)
print("server res",data)
data = json.loads(data.decode())
return data
def _get(self,cmd_list):
print("get-->",cmd_list)
if len(cmd_list) == 1:
print("没有输入要下载的文件名")
return
data_header = {"action":"get","filename":cmd_list[1]}
self.sock.send(json.dumps(data_header).encode())
response = self.get_response()
if response.get("status_code") == 257:
self.sock.send(b"a")
remote_file_size = response.get("file_size")
received_size = 0
base_file_name = cmd_list[1].split()[-1]
f = open(base_file_name,"wb")
m = hashlib.md5()
while received_size < remote_file_size:
data = self.sock.recv(1024)
received_size += len(data)
f.write(data)
m.update(data) else:
print("file is received done!")
local_md5 = m.hexdigest()
remote_md5 = self.sock.recv(1024).decode()
print(local_md5,remote_md5)
if local_md5 == remote_md5:print("文件一致性校验成功!")
else:print("文件一致性校验失败,数据可能不完整!")
else:
print(response.get("status_msg")) def _put(self,cmd_list):
pass def _ls(self,cmd_list):
data = cmd_list
msg={"action":data[0],"dir":data[1]}
self.sock.send(json.dumps(msg).encode())
data = self.get_response()
file_list = data.get("file_list")
print( file_list)
return file_list def interactive(self):
if self.authenticate():
print("---start interactive with %s---" % self.user)
while True:
choice = input("[%s]:"%self.user).strip()
if len(choice) == 0:continue
cmd_list = choice.split()
if hasattr(self,"_%s"%cmd_list[0]):
func = getattr(self,"_%s"%cmd_list[0])
func(cmd_list)
else:
print("Invalid cmd") if __name__ =="__main__":
ftp = FTPClient()
ftp.interactive()

ftpser

 import socketserver
import configparser
from conf import settings
import os
import hashlib STATUS_CODE = {
250 : "Invalid cmd format, e.g: {'action':'get','filename':'test.py','size':344}",
251 : "Invalid cmd ",
252 : "Invalid auth data",
253 : "Wrong username or password",
254 : "Passed authentication",
255 : "Filename doesn't provided",
256 : "File doesn't exist on server",
257 : "ready to send file",
258 : "md5 verification",
259:"Authentication failure",
200:"OK"
} import json
class FTPHandler(socketserver.BaseRequestHandler): def handle(self):
while True:
self.data = self.request.recv(1024).strip()
print("recv:",self.data)
print("client addr:-->",self.client_address[0])
print(self.data)
if not self.data:
print("client closed......")
break
data = json.loads(self.data.decode())
if data.get('action') is not None:
print("---->",hasattr(self,"_auth"))
if hasattr(self,"_%s"%data.get("action")):
func = getattr(self,"_%s"%data.get("action"))
func(data)
else:
print("Invalid cmd format, e.g: {'action':'get','filename':'test.py','size':344}")
self.send_response(250)
else:
print("Invalid cmd")
self.send_response(251) def send_response(self,status_code,data = None):
response = {"status_code":status_code,"status_msg":STATUS_CODE[status_code]}
if data:
response.update(data)
self.request.send(json.dumps(response).encode()) def _auth(self,*args,**kwargs):
data = args[0]
user = self.authenticate(data.get("username"),data.get("password"))
if user is None:
print("Authentication failure")
self.send_response(259)
else:
print("%s Passed authentication"%user["User"])
self.user = user
self.send_response(254) def authenticate(self,username,password):
config = configparser.ConfigParser()
config.read(settings.ACCOUNT_FILE)
if username in config.sections():
if password == config[username]["Password"]:
config[username]["User"] = username
return config[username] def _get(self,*args,**kwargs):
print("-->get")
data = args[0]
file_name = data.get("filename")
print("获取的文件名:",file_name)
self.user_home_dir = "%s/%s"%(settings.USER_HOME,self.user["User"])
self.file_abs_dir = "%s/%s"%(self.user_home_dir,file_name)
print("file abs path:",self.file_abs_dir)
if os.path.isfile(self.file_abs_dir):
file_size = os.path.getsize(self.file_abs_dir)
datas = {"file_size":file_size}
self.send_response(257,datas)
print("ready to send file")
self.request.recv(1024)
file_obj = open(self.file_abs_dir,"rb")
m = hashlib.md5()
for line in file_obj:
self.request.send(line)
m.update(line)
else:
file_obj.close()
md5 = m.hexdigest()
print("file send finish")
print("MD5值:",md5)
self.request.send(md5.encode()) else:
print("remote file not found")
self.send_response(256) def _put(self):
pass def _ls(self,*args):
data = args[0]
cmd = data.get("action")
dir = data.get("dir")
if dir == "." or dir =="":
pass
elif dir == "/":
user_home_files = "%s/%s" % (settings.USER_HOME, self.user["User"])
file_list = os.listdir(user_home_files)
self.send_response(200,data ={"file_list":file_list})

qingku的更多相关文章

随机推荐

  1. java中文件的I/O操作

    java中文件的读写操作 (一) (1)java中文件的字节转成字符读操作 FileInputStream fStream = new FileInputStream("test.txt&q ...

  2. routes.rb和link_to的一些规则

    rails文档中描述了一个知识,link_to方法用于产生链接,但链接是根据routes.rb中的路由规则来产生的.这又分为面向资源和非面向资源两种产生链接的方法.比如 routes.rb文件中有两条 ...

  3. .Net中使用SendGrid Web Api发送邮件(附源码)

    SendGrid是一个第三方的解决邮件发送服务的提供商,在国外使用的比较普遍.国内类似的服务是SendCloud.SendGrid提供的发送邮件方式主要是两种, 一种是SMTP API, 一种是Web ...

  4. (转)基于CAS实现单点登录(SSO):cas client端的退出问题

    出处:http://blog.csdn.net/tch918/article/details/22276627 自从CAS 3.4就很好的支持了单点注销功能,配置也很简单. 之前版本因为在CAS服务器 ...

  5. Linux strace命令

    简介 strace常用来跟踪进程执行时的系统调用和所接收的信号. 在Linux世界,进程不能直接访问硬件设备,当进程需要访问硬件设备(比如读取磁盘文件,接收网络数据等等)时,必须由用户态模式切换至内核 ...

  6. linq to sql 输出SQL语句

    DataClassesDataContext db = new DataClassesDataContext(); db.Log=Response.Output; var result = from ...

  7. SQL周、日、月、年数据统计

    本文只是记录在项目中用到的统计的SQL语句,记一笔以防忘了 /// <summary> /// 获取统计数据 /// </summary> /// <param name ...

  8. MonjaDB —— 基于 Eclipse 的 MongoDB GUI 客户端工具(转载)

    原文链接http://www.oschina.net/question/12_59707 MonjaDB 是一个 MongoDB 的 GUI 客户端工具,提供直观的 MongoDB 数据管理的功能,支 ...

  9. Java环境变量的配置

    1.JAVA_HOMEjdk的路径,我的是安装在C:\Program Files (x86)\Java\jdk1.6.0_182.CLASSPATH .;%JAVA_HOME%\lib\dt.jar; ...

  10. Json解析工具Jackson(简单应用)

    原文http://blog.csdn.net/nomousewch/article/details/8955796 概述 Jackson库(http://jackson.codehaus.org),是 ...