Skip to content

Commit

Permalink
Merge pull request goharbor#592 from tobegit3hub/fix_print_statement_…
Browse files Browse the repository at this point in the history
…in_harbor_py

Replace simplejson with json and fix missed print statement
  • Loading branch information
reasonerjt authored Jul 28, 2016
2 parents faca5d1 + 9b687f2 commit aa03a8f
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions contrib/sdk/harbor-py/harborclient/harborclient.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env python

import requests
import simplejson
import json
import logging
import requests

logging.basicConfig(level=logging.INFO)

Expand Down Expand Up @@ -52,7 +52,8 @@ def get_project_id_from_name(self, project_name):
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
Expand Down Expand Up @@ -107,8 +108,8 @@ def check_project_exist(self, project_name):
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)
Expand All @@ -129,7 +130,7 @@ def set_project_publicity(self, project_id, is_public):
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)
Expand Down Expand Up @@ -175,11 +176,11 @@ def get_users(self, user_name=None):
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)
Expand All @@ -199,9 +200,9 @@ def update_user_profile(self, user_id, email, realname, comment):
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)
Expand Down Expand Up @@ -236,8 +237,8 @@ def change_password(self, user_id, old_password, new_password):
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)
Expand Down

0 comments on commit aa03a8f

Please sign in to comment.