Skip to content

Commit

Permalink
Few minor bug removed after an intensive testing
Browse files Browse the repository at this point in the history
  • Loading branch information
BruXy committed Sep 1, 2016
1 parent b4ee456 commit 74917f9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
6 changes: 5 additions & 1 deletion Makefile
Expand Up @@ -2,7 +2,7 @@

PROJECT=colorize
VERSION=1.0
BUILD=1
BUILD=2

DESTDIR_PLUGIN=/usr/lib64/gimp/2.0/plug-ins/
DESTDIR_SCRIPT=/usr/bin
Expand Down Expand Up @@ -30,3 +30,7 @@ $(TAR_BALL): $(FILE_LIST)
cd ..; tar cvjf $@ colorize/{$(shell tr ' ' ',' <<< "$^")}
mv ../$@ .

ChangeLog:
git log --pretty=format:"* %aD, %an <%ae> %s %n%b" --date=short | \
sed -e 's/\[/\n\t[/' -e 's/^-/\t-/' > ChangeLog

10 changes: 7 additions & 3 deletions colorize.py
Expand Up @@ -125,8 +125,11 @@ def check_api_key():
try:
fp = open(HOME + API_KEY_FILE, 'r')
api_key = fp.readline().rstrip(os.linesep).split('=')[1]
vprint("API key found: '{0}'".format(api_key))
ALG_API_KEY = api_key
if len(api_key) > 16 and ' ' not in api_key:
vprint("API key found: '{0}'".format(api_key))
ALG_API_KEY = api_key
else:
raise ValueError('Valid API key not found.')
except:
ask_for_api_key()
check_api_key() # reload saved key
Expand Down Expand Up @@ -208,7 +211,8 @@ def upload_image(name):
upload_img.close()

if "error" in response:
ALG_API_ERR = "ERROR from API: " + r.json()["error"]["message"]
# ALG_API_ERR = "ERROR from API: " + response.json()["error"]["message"]
ALG_API_ERR = "ERROR from API: " + response["error"]["message"]
print(ALG_API_ERR, file=sys.stderr)
return ''
else:
Expand Down
16 changes: 11 additions & 5 deletions gimp_colorize.py
Expand Up @@ -18,7 +18,7 @@
import sys
import os
sys.path.insert(1, '/usr/bin') # location of colorize.py
#sys.path.insert(2, '/usr/lib64/gimp/2.0/python/')
sys.path.insert(2, '/usr/lib64/gimp/2.0/python/')
import colorize
import gtk
import gimpfu
Expand Down Expand Up @@ -51,15 +51,21 @@ def gui_ask_for_api():
fp = open(colorize.HOME + colorize.API_KEY_FILE, 'w')
fp.write("YOUR_API_KEY={0}{1}".format(api_key, os.linesep))
fp.close()


# process buttong click immediately
message.destroy()
while gtk.events_pending():
gtk.main_iteration()


def gui_message(text, message_type):
"""Gtk dialog for error message display"""
message = gtk.MessageDialog(type=message_type, buttons=gtk.BUTTONS_CLOSE)
message.set_markup(text)
entry.connect("activate", lambda _: d.response(gtk.RESPONSE_CLOSE))
message.run()

message.destroy()
while gtk.events_pending():
gtk.main_iteration()

def save_tmp_file(image, layer, fullpath):
"""Save current image to temporary folder in PNG format.
Expand All @@ -69,7 +75,7 @@ def save_tmp_file(image, layer, fullpath):
if fullpath == None: # is not set for new images
filename = 'temp.png'
else:
filename = colorize.basename(fullpath) + ".png"
filename = os.path.basename(fullpath) + ".png"

fullpath = os.path.join(TEMP, filename)
gimpfu.pdb.file_png_save(image, layer, fullpath, filename, 0, 9, 1, 1, 1, 1, 1)
Expand Down

0 comments on commit 74917f9

Please sign in to comment.