mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-22 10:15:35 +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
|
||||
|
||||
import requests
|
||||
import simplejson
|
||||
import json
|
||||
import logging
|
||||
import requests
|
||||
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
@ -52,7 +52,8 @@ class HarborClient(object):
|
||||
project_id, project_name))
|
||||
return project_id
|
||||
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
|
||||
|
||||
# GET /search
|
||||
@ -107,8 +108,8 @@ class HarborClient(object):
|
||||
def create_project(self, project_name, is_public=False):
|
||||
result = False
|
||||
path = '%s://%s/api/projects' % (self.protocol, self.host)
|
||||
request_body = simplejson.dumps({'project_name': project_name,
|
||||
'public': is_public})
|
||||
request_body = json.dumps({'project_name': project_name,
|
||||
'public': is_public})
|
||||
response = requests.post(path,
|
||||
cookies={'beegosessionID': self.session_id},
|
||||
data=request_body)
|
||||
@ -129,7 +130,7 @@ class HarborClient(object):
|
||||
result = False
|
||||
path = '%s://%s/api/projects/%s/publicity?project_id=%s' % (
|
||||
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,
|
||||
cookies={'beegosessionID': self.session_id},
|
||||
data=request_body)
|
||||
@ -175,11 +176,11 @@ class HarborClient(object):
|
||||
def create_user(self, username, email, password, realname, comment):
|
||||
result = False
|
||||
path = '%s://%s/api/users' % (self.protocol, self.host)
|
||||
request_body = simplejson.dumps({'username': username,
|
||||
'email': email,
|
||||
'password': password,
|
||||
'realname': realname,
|
||||
'comment': comment})
|
||||
request_body = json.dumps({'username': username,
|
||||
'email': email,
|
||||
'password': password,
|
||||
'realname': realname,
|
||||
'comment': comment})
|
||||
response = requests.post(path,
|
||||
cookies={'beegosessionID': self.session_id},
|
||||
data=request_body)
|
||||
@ -199,9 +200,9 @@ class HarborClient(object):
|
||||
result = False
|
||||
path = '%s://%s/api/users/%s?user_id=%s' % (self.protocol, self.host,
|
||||
user_id, user_id)
|
||||
request_body = simplejson.dumps({'email': email,
|
||||
'realname': realname,
|
||||
'comment': comment})
|
||||
request_body = json.dumps({'email': email,
|
||||
'realname': realname,
|
||||
'comment': comment})
|
||||
response = requests.put(path,
|
||||
cookies={'beegosessionID': self.session_id},
|
||||
data=request_body)
|
||||
@ -236,8 +237,8 @@ class HarborClient(object):
|
||||
result = False
|
||||
path = '%s://%s/api/users/%s/password?user_id=%s' % (
|
||||
self.protocol, self.host, user_id, user_id)
|
||||
request_body = simplejson.dumps({'old_password': old_password,
|
||||
'new_password': new_password})
|
||||
request_body = json.dumps({'old_password': old_password,
|
||||
'new_password': new_password})
|
||||
response = requests.put(path,
|
||||
cookies={'beegosessionID': self.session_id},
|
||||
data=request_body)
|
||||
|
Loading…
Reference in New Issue
Block a user