libcanvas/Canvas.py, libgui/GuiCanvasInterface.py: correctly set ImgurApiKey.

libcanvas/CanvasExportStore.py:_exportFileToImgur(): fixed.
libcanvas/CanvasExportStore.py:exportPastebin(): fixed.
This commit is contained in:
Lucio Andrés Illanes Albornoz 2019-09-05 17:13:35 +02:00
parent bffcc644f2
commit 80ff03e4b1
3 changed files with 4 additions and 5 deletions

View File

@ -8,7 +8,6 @@ from CanvasBackend import CanvasBackend
from CanvasJournal import CanvasJournal from CanvasJournal import CanvasJournal
from CanvasExportStore import CanvasExportStore, havePIL, haveUrllib from CanvasExportStore import CanvasExportStore, havePIL, haveUrllib
from CanvasImportStore import CanvasImportStore from CanvasImportStore import CanvasImportStore
from ImgurApiKey import ImgurApiKey
import wx import wx
class Canvas(wx.Panel): class Canvas(wx.Panel):
@ -177,7 +176,6 @@ class Canvas(wx.Panel):
self._canvasDirty, self._canvasDirtyCursor = False, False self._canvasDirty, self._canvasDirtyCursor = False, False
self.canvasMap, self.canvasPos, self.canvasSize, = None, defaultCanvasPos, defaultCanvasSize self.canvasMap, self.canvasPos, self.canvasSize, = None, defaultCanvasPos, defaultCanvasSize
self.defaultCanvasPos, self.defaultCanvasSize, self.defaultCellSize = defaultCanvasPos, defaultCanvasSize, defaultCellSize self.defaultCanvasPos, self.defaultCanvasSize, self.defaultCellSize = defaultCanvasPos, defaultCanvasSize, defaultCellSize
self.imgurApiKey = ImgurApiKey.imgurApiKey
self.parentFrame = parentFrame self.parentFrame = parentFrame
self.parentFrame.onCanvasUpdate(brushSize=self.brushSize, colours=self.brushColours) self.parentFrame.onCanvasUpdate(brushSize=self.brushSize, colours=self.brushColours)

View File

@ -49,7 +49,7 @@ class CanvasExportStore():
"title": imgTitle, \ "title": imgTitle, \
"type": "base64"} "type": "base64"}
requestHeaders = {"Authorization": "Client-ID " + apiKey} requestHeaders = {"Authorization": "Client-ID " + apiKey}
responseHttp = requests.post(ImgurUploadUrl, data=requestData, headers=requestHeaders) responseHttp = requests.post(self.ImgurUploadUrl, data=requestData, headers=requestHeaders)
responseDict = json.loads(responseHttp.text) responseDict = json.loads(responseHttp.text)
if responseHttp.status_code == 200: if responseHttp.status_code == 200:
return [200, responseDict.get("data").get("link")] return [200, responseDict.get("data").get("link")]
@ -105,7 +105,7 @@ class CanvasExportStore():
"api_paste_code": outFile.getvalue().encode(), \ "api_paste_code": outFile.getvalue().encode(), \
"api_paste_name": pasteName, \ "api_paste_name": pasteName, \
"api_paste_private": pastePrivate} "api_paste_private": pastePrivate}
responseHttp = requests.post(PastebinPostUrl, data=requestData) responseHttp = requests.post(self.PastebinPostUrl, data=requestData)
if responseHttp.status_code == 200: if responseHttp.status_code == 200:
if responseHttp.text.startswith("http"): if responseHttp.text.startswith("http"):
return (True, responseHttp.text) return (True, responseHttp.text)

View File

@ -14,6 +14,7 @@ from ToolText import ToolText
from glob import glob from glob import glob
from GuiCanvasInterfaceAbout import GuiCanvasInterfaceAbout from GuiCanvasInterfaceAbout import GuiCanvasInterfaceAbout
from ImgurApiKey import ImgurApiKey
import io, os, random, wx, wx.adv import io, os, random, wx, wx.adv
class GuiCanvasInterface(): class GuiCanvasInterface():
@ -425,7 +426,7 @@ class GuiCanvasInterface():
# #
# __init__(self, parentCanvas, parentFrame): # __init__(self, parentCanvas, parentFrame):
def __init__(self, parentCanvas, parentFrame): def __init__(self, parentCanvas, parentFrame):
self.canvasPathName, self.imgurApiKey = None, None self.canvasPathName, self.imgurApiKey = None, ImgurApiKey.imgurApiKey
self.parentCanvas, self.parentFrame = parentCanvas, parentFrame self.parentCanvas, self.parentFrame = parentCanvas, parentFrame
self.canvasToolRect(None) self.canvasToolRect(None)