# !/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib2
import urllib
import cookielib
import json
import httplib
def gettoken():
data = {'username': '99999@zjtlcb.com', 'password': '1234567'}
post_data = urllib.urlencode(data) # 将post消息化成可以让服务器编码的方式
cj = cookielib.CookieJar() # 获取cookiejar实例
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
# 自己设置User-Agent(可用于伪造获取,防止某些网站防ip注入)
headers = {}
website = "http://127.0.0.1:8000/api2/auth-token/"
req = urllib2.Request(website, post_data, headers)
content = opener.open(req)
s = content.read() # linux下没有gbk编码,只有utf-8编码
print s
print type(s)
text = json.loads(s)
print type(text)
print text['token']
token = text['token']
return token
def check_account_info():
token = gettoken()
print len(token)
token = 'Token' + ' ' + token
print token
url = 'http://192.168.137.1:8000/api2/account/info/'
conn = httplib.HTTPConnection('127.0.0.1', 8000)
headers = {"Authorization": token, "Accept": "application/json; indent=10", "content-type": "application/json"}
print headers
conn.request('GET', url, '', headers)
response = conn.getresponse()
res = response.read()
print res
def list_account():
token = gettoken()
print len(token)
token = 'Token' + ' ' + token
print token
url = 'http://127.0.0.1:8000/api2/accounts/'
conn = httplib.HTTPConnection('127.0.0.1', 8000)
headers = {"Authorization": token, "Accept": "application/json; indent=10", "content-type": "application/json"}
print headers
conn.request('GET', url, '', headers)
response = conn.getresponse()
res = response.read()
print res
def create_account():
token = gettoken()
token = 'Token' + ' ' + token
print token
url = 'http://192.168.137.1:8000/api2/accounts/zhouhaiwu@gmail.com/'
data = {'password': '654321'}
post_data = urllib.urlencode(data) # 将post消息化成可以让服务器编码的方式
request = urllib2.Request(url, post_data)
headers = {"Authorization": token, "Accept": "application/json; indent=10", "content-type": "application/json"}
# request.add_header("Authorization", token, "Accept", "application/json; indent=10", "content-type", "application/json")
request.add_header('Authorization', token)
request.add_header('Accept', 'application/json; indent=10')
request.add_header('content-type', 'application/x-www-form-urlencoded')
request.get_method = lambda: 'PUT'
response = urllib2.urlopen(request)
print response
def update_account():
token = gettoken()
token = 'Token' + ' ' + token
print token
url = 'http://192.168.137.1:8000/api2/accounts/zhouhaiwu@gmail.com/'
data = {'password': '99887766','is_staff':'true'}
post_data = urllib.urlencode(data) # 将post消息化成可以让服务器编码的方式
request = urllib2.Request(url, post_data)
headers = {"Authorization": token, "Accept": "application/json; indent=10", "content-type": "application/json"}
# request.add_header("Authorization", token, "Accept", "application/json; indent=10", "content-type", "application/json")
request.add_header('Authorization', token)
request.add_header('Accept', 'application/json; indent=10')
request.add_header('content-type', 'application/x-www-form-urlencoded')
request.get_method = lambda: 'PUT'
response = urllib2.urlopen(request)
print response
def del_account():
token = gettoken()
token = 'Token' + ' ' + token
print token
url = 'http://192.168.137.1:8000/api2/accounts/newaccount@gmail.com/'
#data = {'password': '654321'}
#post_data = urllib.urlencode(data) # 将post消息化成可以让服务器编码的方式
request = urllib2.Request(url)
headers = {"Authorization": token, "Accept": "application/json; indent=10", "content-type": "application/json"}
# request.add_header("Authorization", token, "Accept", "application/json; indent=10", "content-type", "application/json")
request.add_header('Authorization', token)
request.add_header('Accept', 'application/json; indent=10')
request.add_header('content-type', 'application/x-www-form-urlencoded')
request.get_method = lambda: 'DELETE'
response = urllib2.urlopen(request)
print response.read()
def list_starred_files():
token = gettoken()
print len(token)
token = 'Token' + ' ' + token
print token
url = 'http://127.0.0.1:8000/api2/starredfiles/'
conn = httplib.HTTPConnection('127.0.0.1', 8000)
headers = {"Authorization": token, "Accept": "application/json; indent=10", "content-type": "application/json"}
print headers
conn.request('GET', url, '', headers)
response = conn.getresponse()
res = response.read()
print res.decode('unicode-escape').encode('utf-8')
def add_starred_files():
token = gettoken()
token = 'Token' + ' '+ token
print token
data = {'repo_id': '0219ecf6-0602-4aa7-b9f2-e678255945e5', 'p': '/elk网址.txt'}
post_data = urllib.urlencode(data) # 将post消息化成可以让服务器编码的方式
print post_data
cj = cookielib.CookieJar() # 获取cookiejar实例
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
# 自己设置User-Agent(可用于伪造获取,防止某些网站防ip注入)
headers = {"Authorization": token, "Accept": "application/json; indent=4", "content-type": "application/x-www-form-urlencoded"}
website = 'http://127.0.0.1:8000/api2/starredfiles/'
req = urllib2.Request(website, post_data, headers)
content = opener.open(req)
s = content.read() # linux下没有gbk编码,只有utf-8编码
print s
def unstart_files():
token = gettoken()
token = 'Token' + ' ' + token
print token
url = 'http://127.0.0.1:8000/api2/starredfiles/?repo_id=0219ecf6-0602-4aa7-b9f2-e678255945e5&p=/elk网址.txt'
# data = {'password': '654321'}
# post_data = urllib.urlencode(data) # 将post消息化成可以让服务器编码的方式
request = urllib2.Request(url)
headers = {"Authorization": token, "Accept": "application/json; indent=10", "content-type": "application/json"}
# request.add_header("Authorization", token, "Accept", "application/json; indent=10", "content-type", "application/json")
request.add_header('Authorization', token)
request.add_header('Accept', 'application/json; indent=10')
request.add_header('content-type', 'application/x-www-form-urlencoded')
request.get_method = lambda: 'DELETE'
response = urllib2.urlopen(request)
print response.read()
def list_user_messages():
token = gettoken()
print len(token)
token = 'Token' + ' ' + token
print token
url = 'http://192.168.137.1:8000/api2/user/msgs/015208@zjtlcb.com/'
conn = httplib.HTTPConnection('127.0.0.1', 8000)
headers = {"Authorization": token, "Accept": "application/json; indent=10", "content-type": "application/json"}
print headers
conn.request('GET', url, '', headers)
response = conn.getresponse()
res = response.read()
print res
def reply_user_message():
token = gettoken()
token = 'Token' + ' ' + token
print token
data = {'message': '海武测试'}
post_data = urllib.urlencode(data) # 将post消息化成可以让服务器编码的方式
print post_data
cj = cookielib.CookieJar() # 获取cookiejar实例
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
# 自己设置User-Agent(可用于伪造获取,防止某些网站防ip注入)
headers = {"Authorization": token}
website = "http://127.0.0.1:8000/api2/user/msgs/zhangzhong@gmail.com/"
req = urllib2.Request(website, post_data, headers)
content = opener.open(req)
s = content.read() # linux下没有gbk编码,只有utf-8编码
print s
def unseen_message():
token = '731188058ffbcb4b8615b46c43594f44883f672b'
print len(token)
token = 'Token' + ' ' + token
print token
url = 'http://192.168.137.1:8000/api2/unseen_messages/'
conn = httplib.HTTPConnection('127.0.0.1', 8000)
headers = {"Authorization": token}
print headers
conn.request('GET', url, '', headers)
response = conn.getresponse()
res = response.read()
print res
def list_group():
token = gettoken()
print len(token)
token = 'Token' + ' ' + token
print token
url = 'http://192.168.137.1:8000/api2/groups/'
conn = httplib.HTTPConnection('127.0.0.1', 8000)
headers = {"Authorization": token}
print headers
conn.request('GET', url, '', headers)
response = conn.getresponse()
res = response.read()
print res.decode('unicode-escape').encode('utf-8')
def add_group():
token = gettoken()
token = 'Token' + ' ' + token
print token
url = 'http://192.168.137.1:8000/api2/groups/'
data = {'group_name': '娱乐中心999'}
post_data = urllib.urlencode(data) # 将post消息化成可以让服务器编码的方式
request = urllib2.Request(url, post_data)
headers = {"Authorization": token, "Accept": "application/json; indent=10", "content-type": "application/json"}
# request.add_header("Authorization", token, "Accept", "application/json; indent=10", "content-type", "application/json")
request.add_header('Authorization', token)
request.add_header('Accept', 'application/json; indent=10')
request.add_header('content-type', 'application/x-www-form-urlencoded')
request.get_method = lambda: 'PUT'
response = urllib2.urlopen(request)
print response.read()
def delele_group():
token = gettoken()
token = 'Token' + ' ' + token
print token
url = 'http://127.0.0.1:8000/api2/groups/5/'
# data = {'password': '654321'}
# post_data = urllib.urlencode(data) # 将post消息化成可以让服务器编码的方式
request = urllib2.Request(url)
headers = {"Authorization": token, "Accept": "application/json; indent=10", "content-type": "application/json"}
# request.add_header("Authorization", token, "Accept", "application/json; indent=10", "content-type", "application/json")
request.add_header('Authorization', token)
request.add_header('Accept', 'application/json; indent=10')
request.add_header('content-type', 'application/x-www-form-urlencoded')
request.get_method = lambda: 'DELETE'
response = urllib2.urlopen(request)
print response.read()
def rename_group():
token = gettoken()
token = 'Token' + ' ' + token
print token
data = {'operation': 'rename','newname':'浙商证券'}
post_data = urllib.urlencode(data) # 将post消息化成可以让服务器编码的方式
print post_data
cj = cookielib.CookieJar() # 获取cookiejar实例
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
# 自己设置User-Agent(可用于伪造获取,防止某些网站防ip注入)
headers = {"Authorization": token}
website = "http://127.0.0.1:8000/api2/groups/7/"
req = urllib2.Request(website, post_data, headers)
content = opener.open(req)
s = content.read() # linux下没有gbk编码,只有utf-8编码
print s
def add_group_member():
token = gettoken()
token = 'Token' + ' ' + token
print token
url = 'http://192.168.137.1:8000/api2/groups/4/members/'
data = {'user_name': 'zhouhaiwu@gmail.com'}
post_data = urllib.urlencode(data) # 将post消息化成可以让服务器编码的方式
request = urllib2.Request(url, post_data)
headers = {"Authorization": token, "Accept": "application/json; indent=10", "content-type": "application/json"}
# request.add_header("Authorization", token, "Accept", "application/json; indent=10", "content-type", "application/json")
request.add_header('Authorization', token)
request.add_header('Accept', 'application/json; indent=10')
request.add_header('content-type', 'application/x-www-form-urlencoded')
request.get_method = lambda: 'PUT'
response = urllib2.urlopen(request)
print response.read()
def delete_group_member():
token = gettoken()
token = 'Token' + ' ' + token
print token
url = 'http://192.168.137.1:8000/api2/groups/4/members/'
data = {'user_name': 'zhouhaiwu@gmail.com'}
post_data = urllib.urlencode(data) # 将post消息化成可以让服务器编码的方式
request = urllib2.Request(url, post_data)
headers = {"Authorization": token, "Accept": "application/json; indent=10", "content-type": "application/json"}
# request.add_header("Authorization", token, "Accept", "application/json; indent=10", "content-type", "application/json")
request.add_header('Authorization', token)
request.get_method = lambda: 'DELETE'
response = urllib2.urlopen(request)
print response.read()
def get_group_message():
token = gettoken()
print len(token)
token = 'Token' + ' ' + token
print token
url = 'http://192.168.137.1:8000/api2/group/msgs/1/'
conn = httplib.HTTPConnection('127.0.0.1', 8000)
headers = {"Authorization": token}
print headers
conn.request('GET', url, '', headers)
response = conn.getresponse()
res = response.read()
print res.decode('unicode-escape').encode('utf-8')
def send_group_message():
token = gettoken()
token = 'Token' + ' ' + token
print token
data = {'message': '中国伟大'}
post_data = urllib.urlencode(data) # 将post消息化成可以让服务器编码的方式
print post_data
cj = cookielib.CookieJar() # 获取cookiejar实例
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
# 自己设置User-Agent(可用于伪造获取,防止某些网站防ip注入)
headers = {"Authorization": token}
website = "http://127.0.0.1:8000/api2/group/msgs/1/"
req = urllib2.Request(website, post_data, headers)
content = opener.open(req)
s = content.read() # linux下没有gbk编码,只有utf-8编码
print s
def reply_group_message():
token = '9ec341da308a60047b72f9766b5b98d0d819562c'
token = 'Token' + ' ' + token
print token
data = {'message': '回复中国伟大--99999'}
post_data = urllib.urlencode(data) # 将post消息化成可以让服务器编码的方式
print post_data
cj = cookielib.CookieJar() # 获取cookiejar实例
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
# 自己设置User-Agent(可用于伪造获取,防止某些网站防ip注入)
headers = {"Authorization": token}
website = "http://192.168.137.1:8000/api2/group/1/msg/2/"
req = urllib2.Request(website, post_data, headers)
content = opener.open(req)
s = content.read() # linux下没有gbk编码,只有utf-8编码
print s
def shared_links():
token = gettoken()
print len(token)
token = 'Token' + ' ' + token
print token
url = 'http://192.168.137.1:8000/api2/shared-links/'
conn = httplib.HTTPConnection('127.0.0.1', 8000)
headers = {"Authorization": token}
print headers
conn.request('GET', url, '', headers)
response = conn.getresponse()
res = response.read()
print res.decode('unicode-escape').encode('utf-8')
def create_down_load_link():
token = gettoken()
token = 'Token' + ' ' + token
print token
url = 'http://192.168.137.1:8000/api2/repos/afd1a8c0-bbd3-4c71-9068-0068585e7d98/file/shared-link/'
data = {'type': 'f','p':'/smail.pl'}
post_data = urllib.urlencode(data) # 将post消息化成可以让服务器编码的方式
request = urllib2.Request(url, post_data)
headers = {"Authorization": token, "Accept": "application/json; indent=10", "content-type": "application/json"}
# request.add_header("Authorization", token, "Accept", "application/json; indent=10", "content-type", "application/json")
request.add_header('Authorization', token)
request.add_header('Accept', 'application/json; indent=10')
request.add_header('content-type', 'application/x-www-form-urlencoded')
request.get_method = lambda: 'PUT'
response = urllib2.urlopen(request)
print response.read()
def create_file_share_link():
token = gettoken()
token = 'Token' + ' ' + token
print token
url = 'http://192.168.137.1:8000/api2/repos/afd1a8c0-bbd3-4c71-9068-0068585e7d98/file/shared-link/'
data = {'type': 'f','p':'/elk网址.txt'}
post_data = urllib.urlencode(data) # 将post消息化成可以让服务器编码的方式
request = urllib2.Request(url, post_data)
headers = {"Authorization": token, "Accept": "application/json; indent=10", "content-type": "application/json"}
# request.add_header("Authorization", token, "Accept", "application/json; indent=10", "content-type", "application/json")
request.add_header('Authorization', token)
request.add_header('Accept', 'application/json; indent=10')
request.add_header('content-type', 'application/x-www-form-urlencoded')
request.get_method = lambda: 'PUT'
response = urllib2.urlopen(request)
print response.read()
def delete_file_share_link():
token = gettoken()
token = 'Token' + ' ' + token
print token
url = 'http://192.168.137.1:8000/api2/shared-links/?t=a2019797c6'
#data = {'user_name': 'zhouhaiwu@gmail.com'}
#post_data = urllib.urlencode(data) # 将post消息化成可以让服务器编码的方式
request = urllib2.Request(url)
headers = {"Authorization": token}
# request.add_header("Authorization", token, "Accept", "application/json; indent=10", "content-type", "application/json")
request.add_header('Authorization', token)
request.get_method = lambda: 'DELETE'
response = urllib2.urlopen(request)
print response.read()
def list_shared_directory():
token = gettoken()
print len(token)
token = 'Token' + ' ' + token
print token
url = 'http://192.168.137.1:8000/api2/shared-repos/'
conn = httplib.HTTPConnection('127.0.0.1', 8000)
headers = {"Authorization": token}
print headers
conn.request('GET', url, '', headers)
response = conn.getresponse()
res = response.read()
print res.decode('unicode-escape').encode('utf-8')
def list_be_shared_directory():
token = '9ec341da308a60047b72f9766b5b98d0d819562c'
print len(token)
token = 'Token' + ' ' + token
print token
url = "http://192.168.137.1:8000/api2/beshared-repos/"
conn = httplib.HTTPConnection('127.0.0.1', 8000)
headers = {"Authorization": token}
print headers
conn.request('GET', url, '', headers)
response = conn.getresponse()
res = response.read()
print res.decode('unicode-escape').encode('utf-8')
def share_library():
token = gettoken()
token = 'Token' + ' ' + token
print token
url = "http://192.168.137.1:8000/api2/shared-repos/faf2516c-a35e-4d8d-9520-0a3da4dbc503/?share_type=group&user=015208@zjtlcb.com&group_id=1&permission=rw"
#data = {'type': 'f', 'p': '/smail.pl'}
#post_data = urllib.urlencode(data) # 将post消息化成可以让服务器编码的方式
request = urllib2.Request(url)
headers = {"Authorization": token, "Accept": "application/json; indent=10", "content-type": "application/json"}
# request.add_header("Authorization", token, "Accept", "application/json; indent=10", "content-type", "application/json")
request.add_header('Authorization', token)
request.add_header('Accept', 'application/json; indent=10')
request.add_header('content-type', 'application/x-www-form-urlencoded')
request.get_method = lambda: 'PUT'
response = urllib2.urlopen(request)
print response.read
def get_default_library():
token = gettoken()
print len(token)
token = 'Token' + ' ' + token
print token
url ="http://192.168.137.1:8000/api2/default-repo/"
conn = httplib.HTTPConnection('127.0.0.1', 8000)
headers = {"Authorization": token}
print headers
conn.request('GET', url, '', headers)
response = conn.getresponse()
res = response.read()
print res.decode('unicode-escape').encode('utf-8')
def get_default_library():
token = gettoken()
print len(token)
token = 'Token' + ' ' + token
#data = {'username': '99999@zjtlcb.com', 'password': '1234567'}
post_data ="" # 将post消息化成可以让服务器编码的方式
cj = cookielib.CookieJar() # 获取cookiejar实例
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
# 自己设置User-Agent(可用于伪造获取,防止某些网站防ip注入)
headers = {"Authorization": token}
website = "http://192.168.137.1:8000/api2/default-repo/"
req = urllib2.Request(website, post_data, headers)
content = opener.open(req)
s = content.read() # linux下没有gbk编码,只有utf-8编码
print s
def list_library():
token = gettoken()
print len(token)
token = 'Token' + ' ' + token
print token
url = "http://192.168.137.1:8000/api2/repos/"
conn = httplib.HTTPConnection('127.0.0.1', 8000)
headers = {"Authorization": token,"Accept": "application/json; indent=4"}
print headers
conn.request('GET', url, '', headers)
response = conn.getresponse()
res = response.read()
print res.decode('unicode-escape').encode('utf-8')
def get_library_info():
token = gettoken()
print len(token)
token = 'Token' + ' ' + token
print token
url = "http://192.168.137.1:8000/api2/repos/6f7d78b0-522b-4622-8ca8-c0b1dc1ce8d6/"
conn = httplib.HTTPConnection('127.0.0.1', 8000)
headers = {"Authorization": token,"Accept": "application/json; indent=4"}
print headers
conn.request('GET', url, '', headers)
response = conn.getresponse()
res = response.read()
print res.decode('unicode-escape').encode('utf-8')
def get_library_owner():
token = gettoken()
print len(token)
token = 'Token' + ' ' + token
print token
url = "http://192.168.137.1:8000/api2/repos/faf2516c-a35e-4d8d-9520-0a3da4dbc503/owner/"
conn = httplib.HTTPConnection('127.0.0.1', 8000)
headers = {"Authorization": token,"Accept": "application/json; indent=4"}
print headers
conn.request('GET', url, '', headers)
response = conn.getresponse()
res = response.read()
print res.decode('unicode-escape').encode('utf-8')
def create_library():
token = gettoken()
print len(token)
token = 'Token' + ' ' + token
data = {'name': '黄龙体育中心', 'desc': '老地方'}
post_data = urllib.urlencode(data)
cj = cookielib.CookieJar() # 获取cookiejar实例
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
# 自己设置User-Agent(可用于伪造获取,防止某些网站防ip注入)
headers = {"Authorization": token,"Accept":"application/json; indent=4"}
website = "http://192.168.137.1:8000/api2/repos/"
req = urllib2.Request(website, post_data, headers)
content = opener.open(req)
s = content.read() # linux下没有gbk编码,只有utf-8编码
print s
def delete_library():
token = gettoken()
token = 'Token' + ' ' + token
print token
url = 'http://192.168.137.1:8000/api2/repos/5b655b59-6829-4749-a269-a99fb3fddc9c/'
#data = {'user_name': 'zhouhaiwu@gmail.com'}
#post_data = urllib.urlencode(data) # 将post消息化成可以让服务器编码的方式
request = urllib2.Request(url)
headers = {"Authorization": token}
request.add_header('Authorization', token)
request.add_header('Accept', 'application/json; indent=10')
request.get_method = lambda: 'DELETE'
response = urllib2.urlopen(request)
print response.read()
def download_file():
token = gettoken()
print len(token)
token = 'Token' + ' ' + token
print token
url = "http://192.168.137.1:8000/api2/repos/6f7d78b0-522b-4622-8ca8-c0b1dc1ce8d6/file/?p=/应用监控系统需求大纲.docx"
conn = httplib.HTTPConnection('127.0.0.1', 8000)
headers = {"Authorization": token, "Accept": "application/json; indent=4"}
print headers
conn.request('GET', url, '', headers)
response = conn.getresponse()
res = response.read()
print res.decode('unicode-escape').encode('utf-8')
def get_file_detail():
token = gettoken()
print len(token)
token = 'Token' + ' ' + token
print token
url = "http://192.168.137.1:8000/api2/repos/6f7d78b0-522b-4622-8ca8-c0b1dc1ce8d6/file/detail/?p=/应用监控系统需求大纲.docx"
conn = httplib.HTTPConnection('127.0.0.1', 8000)
headers = {"Authorization": token, "Accept": "application/json; indent=4"}
print headers
conn.request('GET', url, '', headers)
response = conn.getresponse()
res = response.read()
print res.decode('unicode-escape').encode('utf-8')
def create_file():
token = gettoken()
print len(token)
token = 'Token' + ' ' + token
data = {'operation': 'create'}
post_data = urllib.urlencode(data) # 将post消息化成可以让服务器编码的方式
cj = cookielib.CookieJar() # 获取cookiejar实例
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
# 自己设置User-Agent(可用于伪造获取,防止某些网站防ip注入)
headers = {"Authorization": token, "Accept": "application/json; indent=4"}
website = "http://192.168.137.1:8000/api2/repos/6f7d78b0-522b-4622-8ca8-c0b1dc1ce8d6/file/?p=/xxyyy.py"
req = urllib2.Request(website, post_data, headers)
content = opener.open(req)
s = content.read() # linux下没有gbk编码,只有utf-8编码
print s
def rename_file():
token = gettoken()
print len(token)
token = 'Token' + ' ' + token
data = {'operation': 'rename','newname':'a1a2a3.go'}
post_data = urllib.urlencode(data) # 将post消息化成可以让服务器编码的方式
cj = cookielib.CookieJar() # 获取cookiejar实例
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
# 自己设置User-Agent(可用于伪造获取,防止某些网站防ip注入)
headers = {"Authorization": token, "Accept": "application/json; indent=4"}
website = "http://192.168.137.1:8000/api2/repos/6f7d78b0-522b-4622-8ca8-c0b1dc1ce8d6/file/?p=/998877.py"
req = urllib2.Request(website, post_data, headers)
content = opener.open(req)
s = content.read() # linux下没有gbk编码,只有utf-8编码
print s
def move_file():
token = gettoken()
print len(token)
token = 'Token' + ' ' + token
data = {'operation': 'move','dst_repo':'faf2516c-a35e-4d8d-9520-0a3da4dbc503','dst_dir':'/'}
post_data = urllib.urlencode(data) # 将post消息化成可以让服务器编码的方式
cj = cookielib.CookieJar() # 获取cookiejar实例
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
# 自己设置User-Agent(可用于伪造获取,防止某些网站防ip注入)
headers = {"Authorization": token, "Accept": "application/json; indent=4"}
website = "http://192.168.137.1:8000/api2/repos/6f7d78b0-522b-4622-8ca8-c0b1dc1ce8d6/file/?p=/5051.wav"
req = urllib2.Request(website, post_data, headers)
content = opener.open(req)
s = content.read() # linux下没有gbk编码,只有utf-8编码
print s
def copy_file():
token = gettoken()
print len(token)
token = 'Token' + ' ' + token
data = {'dst_repo': 'faf2516c-a35e-4d8d-9520-0a3da4dbc503','dst_dir':'/','file_names':'newfile.pl'}
post_data = urllib.urlencode(data) # 将post消息化成可以让服务器编码的方式
cj = cookielib.CookieJar() # 获取cookiejar实例
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
# 自己设置User-Agent(可用于伪造获取,防止某些网站防ip注入)
headers = {"Authorization": token, "Accept": "application/json; indent=4"}
website = "http://192.168.137.1:8000/api2/repos/6f7d78b0-522b-4622-8ca8-c0b1dc1ce8d6/fileops/copy/"
req = urllib2.Request(website, post_data, headers)
content = opener.open(req)
s = content.read() # linux下没有gbk编码,只有utf-8编码
print s
if __name__ == '__main__':
#list_group()
# delete_group_member()
#get_group_message()
#send_group_message()
#reply_group_message()
#shared_links()
# create_file_share_link()
# delete_file_share_link()
#list_shared_directory()
# list_be_shared_directory()
#share_library()
#get_default_library()
#get_default_library()
#get_library_info()
#get_library_owner()
#create_library()
#list_library()
#delete_library()
#download_file()
#get_file_detail()
#create_file()
#rename_file()
#move_file()
copy_file()