Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

fixes bug 812141

* auth -> client in example.commands
* list_webapps implemented
  • Loading branch information...
commit bd7114ca92506853bacd4f05ab3c6e1d3cb6ceb7 1 parent ce68771
Piotr Zalewa authored November 20, 2012
45  example/commands.py
@@ -5,8 +5,8 @@
5 5
 import json
6 6
 
7 7
 
8  
-def validate_manifest(auth, manifest_url):
9  
-    response = auth.validate_manifest(manifest_url)
  8
+def validate_manifest(client, manifest_url):
  9
+    response = client.validate_manifest(manifest_url)
10 10
     if response.status_code == 201:
11 11
         return {'success': True,
12 12
                 'message': 'Validation issued, '
@@ -16,8 +16,8 @@ def validate_manifest(auth, manifest_url):
16 16
                        'Status code: %d' % response.status_code}
17 17
 
18 18
 
19  
-def is_manifest_valid(auth, manifest_id):
20  
-    response = auth.is_manifest_valid(manifest_id)
  19
+def is_manifest_valid(client, manifest_id):
  20
+    response = client.is_manifest_valid(manifest_id)
21 21
     if response is None:
22 22
         return {'success': True,
23 23
                 'message': "Your manifest hasn't been processed yet"}
@@ -29,8 +29,8 @@ def is_manifest_valid(auth, manifest_id):
29 29
             'message': 'Your manifest is not valid:\n%s' % response}
30 30
 
31 31
 
32  
-def create(auth, manifest_id):
33  
-    response = auth.create(manifest_id)
  32
+def create(client, manifest_id):
  33
+    response = client.create(manifest_id)
34 34
     content = json.loads(response.content)
35 35
     if response.status_code == 201:
36 36
         return {'success': True,
@@ -42,16 +42,19 @@ def create(auth, manifest_id):
42 42
                 'message': response.content}
43 43
 
44 44
 
45  
-def list_webapps(auth):
46  
-    response = auth.list_webapps()
  45
+def list_webapps(client):
  46
+    response = client.list_webapps()
47 47
     content = json.loads(response.content)
48 48
     if response.status_code == 200:
49 49
         return {'success': True,
50 50
                 'message': content}
  51
+    else:
  52
+        return {'success': False,
  53
+                'message': response.content}
51 54
 
52 55
 
53  
-def status(auth, app_id):
54  
-    response = auth.status(app_id)
  56
+def status(client, app_id):
  57
+    response = client.status(app_id)
55 58
     if response.status_code != 200:
56 59
         return {'success': False,
57 60
                 'message': 'Error, status code: %d, \nMessage: %s' % (
@@ -62,7 +65,7 @@ def status(auth, app_id):
62 65
                 ['%s: %s' % (k, v) for k, v in content.items()])}
63 66
 
64 67
 
65  
-def update(auth, app_id):
  68
+def update(client, app_id):
66 69
 
67 70
     def get_value(key, val):
68 71
         variable = raw_input('%s (%s): ' % (key, val))
@@ -77,7 +80,7 @@ def get_value(key, val):
77 80
     truthy_keys = ['name', 'categories', 'support_email', 'device_types',
78 81
                    'payment_type', 'privacy_policy', 'summary']
79 82
     # obtaining current data
80  
-    data = json.loads(auth.status(app_id).content)
  83
+    data = json.loads(client.status(app_id).content)
81 84
     data['payment_type'] = data['premium_type']
82 85
     for key in data.keys():
83 86
         if key not in editable_keys:
@@ -92,7 +95,7 @@ def get_value(key, val):
92 95
                     data[key] = variable.split(',')
93 96
                 else:
94 97
                     data[key] = variable
95  
-    response = auth.update(app_id, data)
  98
+    response = client.update(app_id, data)
96 99
     if response.status_code != 202:
97 100
         return {'success': False,
98 101
                 'message': 'Error, status code: %d, \nMessage: %s' % (
@@ -101,8 +104,8 @@ def get_value(key, val):
101 104
             'message': 'Your app has been updated'}
102 105
 
103 106
 
104  
-def add_screenshot(auth, app_id, filename):
105  
-    response = auth.create_screenshot(app_id, filename)
  107
+def add_screenshot(client, app_id, filename):
  108
+    response = client.create_screenshot(app_id, filename)
106 109
     if response.status_code != 201:
107 110
         return {'success': False,
108 111
                 'message': 'Error, status code: %d, \nMessage: %s' % (
@@ -113,8 +116,8 @@ def add_screenshot(auth, app_id, filename):
113 116
                 ['%s: %s' % (k, v) for k, v in content.items()])}
114 117
 
115 118
 
116  
-def get_screenshot(auth, screenshot_id):
117  
-    response = auth.get_screenshot(screenshot_id)
  119
+def get_screenshot(client, screenshot_id):
  120
+    response = client.get_screenshot(screenshot_id)
118 121
     if response.status_code != 200:
119 122
         return {'success': False,
120 123
                 'message': 'Error, status code: %d, \nMessage: %s' % (
@@ -125,8 +128,8 @@ def get_screenshot(auth, screenshot_id):
125 128
                 ['%s: %s' % (k, v) for k, v in content.items()])}
126 129
 
127 130
 
128  
-def del_screenshot(auth, screenshot_id):
129  
-    response = auth.del_screenshot(screenshot_id)
  131
+def del_screenshot(client, screenshot_id):
  132
+    response = client.del_screenshot(screenshot_id)
130 133
     if response.status_code != 204:
131 134
         return {'success': False,
132 135
                 'message': 'Error, status code: %d, \nMessage: %s' % (
@@ -135,8 +138,8 @@ def del_screenshot(auth, screenshot_id):
135 138
             'message': 'Screenshot deleted'}
136 139
 
137 140
 
138  
-def get_categories(auth):
139  
-    response = auth.get_categories()
  141
+def get_categories(client):
  142
+    response = client.get_categories()
140 143
     if response.status_code != 200:
141 144
         return {'success': False,
142 145
                 'message': 'Error, status code: %d, \nMessage: %s' % (
2  marketplace/client.py
@@ -125,7 +125,7 @@ def list_webapps(self):
125 125
         :returns: list
126 126
         """
127 127
         response = self.conn.fetch('GET', self.url('create'))
128  
-        print response
  128
+        return response
129 129
 
130 130
     def update(self, app_id, data):
131 131
         """Update app identified by app_id with data

0 notes on commit bd7114c

Please sign in to comment.
Something went wrong with that request. Please try again.