mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-23 02:35:17 +01:00
Replace simplejson with json and fix missed print statement
This commit is contained in:
parent
405f013e7a
commit
9b687f2ed6
@ -1,8 +1,8 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
import requests
|
import json
|
||||||
import simplejson
|
|
||||||
import logging
|
import logging
|
||||||
|
import requests
|
||||||
|
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
|
||||||
@ -52,7 +52,8 @@ class HarborClient(object):
|
|||||||
project_id, project_name))
|
project_id, project_name))
|
||||||
return project_id
|
return project_id
|
||||||
else:
|
else:
|
||||||
pritn("Fail to get project id from project name", project_name)
|
logging.error("Fail to get project id from project name",
|
||||||
|
project_name)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# GET /search
|
# GET /search
|
||||||
@ -107,8 +108,8 @@ class HarborClient(object):
|
|||||||
def create_project(self, project_name, is_public=False):
|
def create_project(self, project_name, is_public=False):
|
||||||
result = False
|
result = False
|
||||||
path = '%s://%s/api/projects' % (self.protocol, self.host)
|
path = '%s://%s/api/projects' % (self.protocol, self.host)
|
||||||
request_body = simplejson.dumps({'project_name': project_name,
|
request_body = json.dumps({'project_name': project_name,
|
||||||
'public': is_public})
|
'public': is_public})
|
||||||
response = requests.post(path,
|
response = requests.post(path,
|
||||||
cookies={'beegosessionID': self.session_id},
|
cookies={'beegosessionID': self.session_id},
|
||||||
data=request_body)
|
data=request_body)
|
||||||
@ -129,7 +130,7 @@ class HarborClient(object):
|
|||||||
result = False
|
result = False
|
||||||
path = '%s://%s/api/projects/%s/publicity?project_id=%s' % (
|
path = '%s://%s/api/projects/%s/publicity?project_id=%s' % (
|
||||||
self.protocol, self.host, project_id, project_id)
|
self.protocol, self.host, project_id, project_id)
|
||||||
request_body = simplejson.dumps({'public': is_public})
|
request_body = json.dumps({'public': is_public})
|
||||||
response = requests.put(path,
|
response = requests.put(path,
|
||||||
cookies={'beegosessionID': self.session_id},
|
cookies={'beegosessionID': self.session_id},
|
||||||
data=request_body)
|
data=request_body)
|
||||||
@ -175,11 +176,11 @@ class HarborClient(object):
|
|||||||
def create_user(self, username, email, password, realname, comment):
|
def create_user(self, username, email, password, realname, comment):
|
||||||
result = False
|
result = False
|
||||||
path = '%s://%s/api/users' % (self.protocol, self.host)
|
path = '%s://%s/api/users' % (self.protocol, self.host)
|
||||||
request_body = simplejson.dumps({'username': username,
|
request_body = json.dumps({'username': username,
|
||||||
'email': email,
|
'email': email,
|
||||||
'password': password,
|
'password': password,
|
||||||
'realname': realname,
|
'realname': realname,
|
||||||
'comment': comment})
|
'comment': comment})
|
||||||
response = requests.post(path,
|
response = requests.post(path,
|
||||||
cookies={'beegosessionID': self.session_id},
|
cookies={'beegosessionID': self.session_id},
|
||||||
data=request_body)
|
data=request_body)
|
||||||
@ -199,9 +200,9 @@ class HarborClient(object):
|
|||||||
result = False
|
result = False
|
||||||
path = '%s://%s/api/users/%s?user_id=%s' % (self.protocol, self.host,
|
path = '%s://%s/api/users/%s?user_id=%s' % (self.protocol, self.host,
|
||||||
user_id, user_id)
|
user_id, user_id)
|
||||||
request_body = simplejson.dumps({'email': email,
|
request_body = json.dumps({'email': email,
|
||||||
'realname': realname,
|
'realname': realname,
|
||||||
'comment': comment})
|
'comment': comment})
|
||||||
response = requests.put(path,
|
response = requests.put(path,
|
||||||
cookies={'beegosessionID': self.session_id},
|
cookies={'beegosessionID': self.session_id},
|
||||||
data=request_body)
|
data=request_body)
|
||||||
@ -236,8 +237,8 @@ class HarborClient(object):
|
|||||||
result = False
|
result = False
|
||||||
path = '%s://%s/api/users/%s/password?user_id=%s' % (
|
path = '%s://%s/api/users/%s/password?user_id=%s' % (
|
||||||
self.protocol, self.host, user_id, user_id)
|
self.protocol, self.host, user_id, user_id)
|
||||||
request_body = simplejson.dumps({'old_password': old_password,
|
request_body = json.dumps({'old_password': old_password,
|
||||||
'new_password': new_password})
|
'new_password': new_password})
|
||||||
response = requests.put(path,
|
response = requests.put(path,
|
||||||
cookies={'beegosessionID': self.session_id},
|
cookies={'beegosessionID': self.session_id},
|
||||||
data=request_body)
|
data=request_body)
|
||||||
|
Loading…
Reference in New Issue
Block a user