diff -Nru dastash-1.0.1/bin/da-space dastash-1.1/bin/da-space
--- dastash-1.0.1/bin/da-space 1970-01-01 00:00:00.000000000 +0000
+++ dastash-1.1/bin/da-space 2011-06-09 18:02:28.000000000 +0000
@@ -0,0 +1,35 @@
+#!/usr/bin/python
+#
+# Copyright (c) 2011, Martin Owens
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the Affero GNU General Public License as published
+# by the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see
+#
+# Depends on the following fork of python-oauth2 6.0
+#
+"""
+Use the da-stash module to See how much space we have on deviantArt.
+"""
+
+import os
+import sys
+sys.path.insert(1, './')
+sys.path.insert(1, '../lib')
+
+from dastash import dAStash
+
+if __name__ == '__main__':
+ dA = dAStash('Command Line')
+ print "User: %s, Space: %s" % (dA.whoami(), dA.space())
+ sys.exit(0)
+
diff -Nru dastash-1.0.1/debian/changelog dastash-1.1/debian/changelog
--- dastash-1.0.1/debian/changelog 2011-06-09 18:37:05.000000000 +0000
+++ dastash-1.1/debian/changelog 2011-06-09 18:37:05.000000000 +0000
@@ -1,23 +1,11 @@
-dastash (1.0.1-0ubuntu8) natty; urgency=low
+dastash (1.1-0ubuntu2) natty; urgency=low
- * Fix location of gimp plugin.
+ * New Upstream Version
- -- Martin Owens (DoctorMO) Thu, 19 May 2011 22:30:23 -0400
-
-dastash (1.0.1-0ubuntu6) natty; urgency=low
-
- * Move to pygtk.
-
- -- Martin Owens (DoctorMO) Thu, 19 May 2011 22:21:22 -0400
-
-dastash (1.0-0ubuntu3) natty; urgency=low
-
- * for Natty
-
- -- Martin Owens (DoctorMO) Thu, 19 May 2011 20:15:13 -0400
+ -- Martin Owens (DoctorMO) Thu, 09 Jun 2011 14:18:04 -0400
dastash (1.0-0ubuntu1) maverick; urgency=low
* Inital Commit
- -- Martin Owens (DoctorMO) Thu, 19 May 2011 18:37:09 -0400
+ -- Martin Owens (DoctorMO) Mon, 07 Mar 2011 18:38:12 -0500
diff -Nru dastash-1.0.1/debian/control dastash-1.1/debian/control
--- dastash-1.0.1/debian/control 2011-06-09 18:37:05.000000000 +0000
+++ dastash-1.1/debian/control 2011-06-09 18:37:05.000000000 +0000
@@ -12,7 +12,6 @@
Package: python-dastash
Architecture: all
Depends: ${python:Depends}, ${misc:Depends},
- gir1.0-gtk-2.0 | gir1.2-gtk-2.0,
python-poster (>=0.8.1),
python-oauth2 (>=6.0),
python-webkit
diff -Nru dastash-1.0.1/gimp/deviantart-plugin.py dastash-1.1/gimp/deviantart-plugin.py
--- dastash-1.0.1/gimp/deviantart-plugin.py 2011-05-19 22:44:35.000000000 +0000
+++ dastash-1.1/gimp/deviantart-plugin.py 2011-05-22 14:55:14.000000000 +0000
@@ -67,7 +67,7 @@
],
results=[],
function=(stash),
- menu=("/Image/Pu_blish to"),
+ menu=("/File/Save/Pu_blish to"),
domain=("gimp20-python", gimp.locale_directory)
)
diff -Nru dastash-1.0.1/inkscape/deviantart-publish.py dastash-1.1/inkscape/deviantart-publish.py
--- dastash-1.0.1/inkscape/deviantart-publish.py 2011-05-19 22:42:24.000000000 +0000
+++ dastash-1.1/inkscape/deviantart-publish.py 2011-06-09 17:51:31.000000000 +0000
@@ -94,7 +94,7 @@
inkex.errormsg("Saved SVG is missing, failure to save?")
if os.path.exists(raster):
- dA = dAStash('Inkscape')
+ dA = dAStash('Inkscape', quiet=True)
# Collect all our meta data here
kwargs = {}
kwargs['keywords'] = self.options.keywords or ''
diff -Nru dastash-1.0.1/lib/dastash.py dastash-1.1/lib/dastash.py
--- dastash-1.0.1/lib/dastash.py 2011-05-20 02:16:40.000000000 +0000
+++ dastash-1.1/lib/dastash.py 2011-06-09 18:08:39.000000000 +0000
@@ -54,8 +54,9 @@
SERVER_SPEC = 'draft10'
SERVER_OAUTH = 'https://www.deviantart.com/oauth2/%s/' % SERVER_SPEC
API = {
- 'placebo' : 'http://www.deviantart.com/api/draft10/placebo',
- 'whoami' : 'http://www.deviantart.com/api/draft10/user/whoami',
+ 'placebo' : 'http://www.deviantart.com/api/%s/placebo' % SERVER_SPEC,
+ 'whoami' : 'http://www.deviantart.com/api/%s/user/whoami' % SERVER_SPEC,
+ 'space' : 'https://www.deviantart.com/api/%s/stash/space' % SERVER_SPEC,
'submit' : 'http://submit.deviantart.com/%s/api' % SERVER_SPEC,
}
@@ -156,7 +157,7 @@
"""DeviantArt Stashing API"""
def __init__(self, default_folder='Desktop Uploads',
client_id=CLIENT_ID, client_secret=CLIENT_SECRET,
- web_callback=None):
+ web_callback=None, quiet=False):
self.folder = default_folder
self.open_window = web_callback or self._open_window
self.client_id = client_id
@@ -165,6 +166,11 @@
logging.debug("Feeding Fella a Llama...")
self.session = self.load_token('session') # session token
self.refresh = self.load_token('auth') # refresh token
+ self.warn = quiet and logging.warn or self._none
+
+ def _none(self):
+ """Handle warnings we don't want to do anything about"""
+ return None
def get_code(self):
"""Get a new token and refresh from deviantArt"""
@@ -177,7 +183,7 @@
try:
window = AuthWindow(url)
except:
- logging.warn("GUI Error!\n")
+ logging.error("GUI Error!\n")
sys.exit()
else:
return window.code
@@ -196,7 +202,7 @@
grant_type='authorization_code',
)
except oauth2.Error, msg:
- logging.warn("Error getting auth token: %s\n" % msg)
+ self.warn("Error getting auth token: %s\n" % msg)
else:
return self.store_tokens(response)
@@ -209,7 +215,7 @@
grant_type='refresh_token',
)
except oauth2.Error, msg:
- logging.warn("Error refreshing auth token: %s\n" % msg)
+ self.warn("Error refreshing auth token: %s\n" % msg)
else:
return self.store_tokens(response)
@@ -264,9 +270,9 @@
access_token=self.session, token_param='token')
if returned['status'] != '200':
if returned.has_key('www-authenticate'):
- logging.warn("Request Failed: %s" % returned.get('www-authenticate'))
+ self.warn("Request Failed: %s" % returned.get('www-authenticate'))
else:
- logging.warn("Unknown failure (%s): %s" % (returned['status'], str(returned)))
+ self.warn("Unknown failure (%s): %s" % (returned['status'], str(returned)))
if content:
try:
return json.loads(content)
@@ -274,18 +280,20 @@
logging.debug("No JSON in request. Ignoring.")
return returned # Send the headers back
- def user_request(self, uri, fields=None, files=None, rerequest=True):
+ def user_request(self, uri, fields=None, files=None, rreq=True):
"""Make a user level request (auth handle)"""
if not self.session:
self.get_token()
response = self.request(uri, fields, files=files)
if isinstance(response, dict):
# Our authentication has failed, try again.
- if response.get('status', '200') == '401' and rerequest:
- self.session = None
- return self.user_request( uri, fields, files, rerequest=False )
- elif response.has_key('error'):
- logging.warn("Request Error: %s" % response.get('error-desc', 'Unknown'))
+ if response.get('status', '200') == 'error' and rreq:
+ if response.get('error', 'none') == 'expired_token':
+ self.session = None
+ return self.user_request(uri, fields, files, rreq=False)
+ else:
+ logging.error("Request Error: %s" % response.get(
+ 'error_description', 'Unknown'))
else:
logging.debug("Request response failure: '%s'" % response)
# Text only response
@@ -293,7 +301,18 @@
def whoami(self):
"""Return the user we're logged on as"""
- return self.user_request(API['whoami'])
+ user = self.user_request(API['whoami'])
+ return user.get('symbol', '!') + user.get('username', 'unknown')
+
+ def space(self):
+ """Return the amount of space we have left"""
+ count = float(self.user_request(API['space']).get('available_space', 0))
+ powers = [' Bytes','KiB', 'MiB', 'GiB', 'TiB']
+ power = 0
+ while count > 1024:
+ count /= 1024
+ power += 1
+ return "%.2f%s" % (count, powers[power])
def submit(self, name, files, **fields):
"""Submit a new deviantArt stash item"""
@@ -308,7 +327,7 @@
logging.debug("Submitting to %s's Stash" % user)
return self.user_request(API['submit'], fields=fields, files=files)
else:
- logging.warn("Submit to deviantArt failed! Woe!")
+ logging.error("Submit to deviantArt failed! Woe!")
return None
def get_url(self, stashid):
diff -Nru dastash-1.0.1/MANIFEST.in dastash-1.1/MANIFEST.in
--- dastash-1.0.1/MANIFEST.in 2011-05-19 22:20:07.000000000 +0000
+++ dastash-1.1/MANIFEST.in 2011-06-09 18:10:03.000000000 +0000
@@ -2,6 +2,6 @@
include COPYING
include MANIFEST.in
include lib/dastash.py
-include bin/da-submit
+include bin/*
include inkscape/*.*
include gimp/*.*
diff -Nru dastash-1.0.1/PKG-INFO dastash-1.1/PKG-INFO
--- dastash-1.0.1/PKG-INFO 2011-05-20 02:20:21.000000000 +0000
+++ dastash-1.1/PKG-INFO 2011-06-09 18:11:37.000000000 +0000
@@ -1,6 +1,6 @@
Metadata-Version: 1.0
Name: dastash
-Version: 1.0.1
+Version: 1.1.0
Summary: Python module for sending files to deviantArt
Home-page: https://launchpad.net/dastash
Author: Martin Owens
diff -Nru dastash-1.0.1/setup.py dastash-1.1/setup.py
--- dastash-1.0.1/setup.py 2011-05-20 02:19:53.000000000 +0000
+++ dastash-1.1/setup.py 2011-06-09 18:11:01.000000000 +0000
@@ -29,7 +29,7 @@
setup(
name = 'dastash',
- version = '1.0.1',
+ version = '1.1.0',
description = 'Python module for sending files to deviantArt',
long_description = "Using OAuth2.0 draft10, this library authenticates and sends images or texts to deviantArt.",
author = 'Martin Owens',
@@ -38,7 +38,7 @@
platforms = 'linux',
license = 'GPLv3',
py_modules = [ 'dastash' ],
- scripts = [ 'bin/da-submit' ],
+ scripts = [ 'bin/da-submit', 'bin/da-space' ],
package_dir = {'': 'lib'},
)