Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add list apps #21

Merged
merged 2 commits into from

3 participants

@zalun
Owner

No description provided.

zalun added some commits
@zalun zalun Url of the repo changed
command added
ce68771
@zalun zalun fixes bug 812141
* auth -> client in example.commands
* list_webapps implemented
bd7114c
@cvan
Collaborator

you don't want to return?

Collaborator

you do in bd7114c, nvm

@andymckay
Owner

r+

@zalun zalun merged commit c29cb9a into mozilla:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 16, 2012
  1. @zalun

    Url of the repo changed

    zalun authored
    command added
Commits on Nov 20, 2012
  1. @zalun

    fixes bug 812141

    zalun authored
    * auth -> client in example.commands
    * list_webapps implemented
This page is out of date. Refresh to see the latest.
View
2  example/README.rst
@@ -19,7 +19,7 @@ Usage
* Validate manifest. Will return ``manifest_id`` which is needed for the next steps::
- python main.py validate_manifest http://mozilla.github.com/MarketplaceClientExample/manifest.webapp
+ python main.py validate_manifest http://mozilla.github.com/Marketplace.Python/manifest.webapp
* Check if the manifest is valid::
View
49 example/commands.py
@@ -5,8 +5,8 @@
import json
-def validate_manifest(auth, manifest_url):
- response = auth.validate_manifest(manifest_url)
+def validate_manifest(client, manifest_url):
+ response = client.validate_manifest(manifest_url)
if response.status_code == 201:
return {'success': True,
'message': 'Validation issued, '
@@ -16,8 +16,8 @@ def validate_manifest(auth, manifest_url):
'Status code: %d' % response.status_code}
-def is_manifest_valid(auth, manifest_id):
- response = auth.is_manifest_valid(manifest_id)
+def is_manifest_valid(client, manifest_id):
+ response = client.is_manifest_valid(manifest_id)
if response is None:
return {'success': True,
'message': "Your manifest hasn't been processed yet"}
@@ -29,8 +29,8 @@ def is_manifest_valid(auth, manifest_id):
'message': 'Your manifest is not valid:\n%s' % response}
-def create(auth, manifest_id):
- response = auth.create(manifest_id)
+def create(client, manifest_id):
+ response = client.create(manifest_id)
content = json.loads(response.content)
if response.status_code == 201:
return {'success': True,
@@ -42,8 +42,19 @@ def create(auth, manifest_id):
'message': response.content}
-def status(auth, app_id):
- response = auth.status(app_id)
+def list_webapps(client):
+ response = client.list_webapps()
+ content = json.loads(response.content)
+ if response.status_code == 200:
+ return {'success': True,
+ 'message': content}
+ else:
+ return {'success': False,
+ 'message': response.content}
+
+
+def status(client, app_id):
+ response = client.status(app_id)
if response.status_code != 200:
return {'success': False,
'message': 'Error, status code: %d, \nMessage: %s' % (
@@ -54,7 +65,7 @@ def status(auth, app_id):
['%s: %s' % (k, v) for k, v in content.items()])}
-def update(auth, app_id):
+def update(client, app_id):
def get_value(key, val):
variable = raw_input('%s (%s): ' % (key, val))
@@ -69,7 +80,7 @@ def get_value(key, val):
truthy_keys = ['name', 'categories', 'support_email', 'device_types',
'payment_type', 'privacy_policy', 'summary']
# obtaining current data
- data = json.loads(auth.status(app_id).content)
+ data = json.loads(client.status(app_id).content)
data['payment_type'] = data['premium_type']
for key in data.keys():
if key not in editable_keys:
@@ -84,7 +95,7 @@ def get_value(key, val):
data[key] = variable.split(',')
else:
data[key] = variable
- response = auth.update(app_id, data)
+ response = client.update(app_id, data)
if response.status_code != 202:
return {'success': False,
'message': 'Error, status code: %d, \nMessage: %s' % (
@@ -93,8 +104,8 @@ def get_value(key, val):
'message': 'Your app has been updated'}
-def add_screenshot(auth, app_id, filename):
- response = auth.create_screenshot(app_id, filename)
+def add_screenshot(client, app_id, filename):
+ response = client.create_screenshot(app_id, filename)
if response.status_code != 201:
return {'success': False,
'message': 'Error, status code: %d, \nMessage: %s' % (
@@ -105,8 +116,8 @@ def add_screenshot(auth, app_id, filename):
['%s: %s' % (k, v) for k, v in content.items()])}
-def get_screenshot(auth, screenshot_id):
- response = auth.get_screenshot(screenshot_id)
+def get_screenshot(client, screenshot_id):
+ response = client.get_screenshot(screenshot_id)
if response.status_code != 200:
return {'success': False,
'message': 'Error, status code: %d, \nMessage: %s' % (
@@ -117,8 +128,8 @@ def get_screenshot(auth, screenshot_id):
['%s: %s' % (k, v) for k, v in content.items()])}
-def del_screenshot(auth, screenshot_id):
- response = auth.del_screenshot(screenshot_id)
+def del_screenshot(client, screenshot_id):
+ response = client.del_screenshot(screenshot_id)
if response.status_code != 204:
return {'success': False,
'message': 'Error, status code: %d, \nMessage: %s' % (
@@ -127,8 +138,8 @@ def del_screenshot(auth, screenshot_id):
'message': 'Screenshot deleted'}
-def get_categories(auth):
- response = auth.get_categories()
+def get_categories(client):
+ response = client.get_categories()
if response.status_code != 200:
return {'success': False,
'message': 'Error, status code: %d, \nMessage: %s' % (
View
1  example/main.py
@@ -9,6 +9,7 @@
COMMANDS = {'validate_manifest': commands.validate_manifest,
'is_manifest_valid': commands.is_manifest_valid,
'create': commands.create,
+ 'list_webapps': commands.list_webapps,
'status': commands.status,
'update': commands.update,
'add_screenshot': commands.add_screenshot,
View
8 marketplace/client.py
@@ -119,6 +119,14 @@ def create(self, manifest_id):
return self.conn.fetch('POST', self.url('create'),
{'manifest': '%s' % manifest_id})
+ def list_webapps(self):
+ """Lists all webapps owned by user
+
+ :returns: list
+ """
+ response = self.conn.fetch('GET', self.url('create'))
+ return response
+
def update(self, app_id, data):
"""Update app identified by app_id with data
View
2  setup.py
@@ -2,7 +2,7 @@
setup(
name='Marketplace',
- version='0.1.2a',
+ version='0.1.3a',
packages=['marketplace', ],
license='Mozilla Public License (MPL 2.0)',
author='Piotr Zalewa',
Something went wrong with that request. Please try again.