Skip to content

Commit

Permalink
fix #44 problems with domain changes
Browse files Browse the repository at this point in the history
  • Loading branch information
elesdoar committed Jul 8, 2016
1 parent 18b35a1 commit 07e3c5e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
22 changes: 14 additions & 8 deletions CartoDBPlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
This script initializes the plugin, making it known to QGIS.
"""
# Import the PyQt and QGIS libraries
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtCore import Qt, QCoreApplication, QObject, QSettings, QTranslator, qDebug, qVersion
from PyQt4.QtGui import QMenu, QIcon, QAction, QProgressBar

from qgis.core import QgsMessageLog, QgsPluginLayerRegistry, QgsMapLayerRegistry
from osgeo import gdal
Expand All @@ -48,7 +48,7 @@ class CartoDBPlugin(QObject):
PLUGIN_DIR = os.path.dirname(os.path.abspath(__file__))

def __init__(self, iface):
super(QObject, self).__init__()
QObject.__init__(self)
QgsMessageLog.logMessage('GDAL Version: ' + str(gdal.VersionInfo('VERSION_NUM')), 'CartoDB Plugin', QgsMessageLog.INFO)

# Save reference to the QGIS interface
Expand Down Expand Up @@ -78,6 +78,15 @@ def __init__(self, iface):
self.countLoadingLayers = 0
self.countLoadedLayers = 0

self._cdbMenu = None
self._mainAction = None
self._loadDataAction = None
self._createVizAction = None
self._addSQLAction = None
self.toolbar = CartoDBToolbar()
self._toolbarAction = None
self._menu = None

def initGui(self):
self._cdbMenu = QMenu("CartoDB plugin", self.iface.mainWindow())
self._cdbMenu.setIcon(QIcon(":/plugins/qgis-cartodb/images/icon.png"))
Expand All @@ -90,7 +99,6 @@ def initGui(self):
self._addSQLAction = QAction(self.tr('Add SQL CartoDB Layer'), self.iface.mainWindow())
self._addSQLAction.setIcon(QIcon(":/plugins/qgis-cartodb/images/icons/sql.png"))

self.toolbar = CartoDBToolbar()
self.toolbar.setClick(self.connectionManager)
self.toolbar.error.connect(self.toolbarError)
self._toolbarAction = self.iface.addWebToolBarWidget(self.toolbar)
Expand Down Expand Up @@ -251,14 +259,12 @@ def addLayer(fileName, tableName):

dlg.addedLayer.connect(addLayer)
dlg.show()

result = dlg.exec_()
dlg.exec_()

def createNewMap(self):
dlg = CartoDBPluginCreateViz(self.toolbar, self.iface)
dlg.show()

result = dlg.exec_()
dlg.exec_()

def addLoadingMsg(self, countLayers, barText='Downloading datasets'):
barText = self.tr(barText)
Expand Down
8 changes: 4 additions & 4 deletions cartodb/cartodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class CartoDBBase(object):
""" basic client to access cartodb api """
MAX_GET_QUERY_LEN = 2048

def __init__(self, cartodb_domain, host='cartodb.com', protocol='https', api_version='v2'):
def __init__(self, cartodb_domain, host='carto.com', protocol='https', api_version='v2'):
self.resource_url = RESOURCE_URL % {'user': cartodb_domain, 'domain': host, 'protocol': protocol, 'api_version': api_version}

def req(self, url, http_method="GET", http_headers=None, body=''):
Expand Down Expand Up @@ -95,7 +95,7 @@ class CartoDBOAuth(CartoDBBase):
"""
This client allows to auth in cartodb using oauth.
"""
def __init__(self, key, secret, email, password, cartodb_domain, host='cartodb.com', protocol='https', proxy_info=None, *args, **kwargs):
def __init__(self, key, secret, email, password, cartodb_domain, host='carto.com', protocol='https', proxy_info=None, *args, **kwargs):
super(CartoDBOAuth, self).__init__(cartodb_domain, host, protocol, *args, **kwargs)

self.consumer_key = key
Expand Down Expand Up @@ -132,11 +132,11 @@ def req(self, url, http_method="GET", http_headers=None, body=''):

class CartoDBAPIKey(CartoDBBase):
"""
this class provides you access to auth CartoDB API using your API. You can find your API key in https://USERNAME.cartodb.com/your_apps/api_key.
this class provides you access to auth CartoDB API using your API. You can find your API key in https://USERNAME.carto.com/your_apps/api_key.
this method is easier than use the oauth authentification but if less secure, it is recommended to use only using the https endpoint
"""

def __init__(self, api_key, cartodb_domain, host='cartodb.com', protocol='https', proxy_info=None, *args, **kwargs):
def __init__(self, api_key, cartodb_domain, host='carto.com', protocol='https', proxy_info=None, *args, **kwargs):
super(CartoDBAPIKey, self).__init__(cartodb_domain, host, protocol, *args, **kwargs)
self.api_key = api_key

Expand Down
2 changes: 1 addition & 1 deletion cartodb/cartodbapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class CartoDBApi(QObject):
progress = pyqtSignal(int, int)
error = pyqtSignal(object)

def __init__(self, cartodbUser, apiKey, multiuser=False, hostname='cartodb.com'):
def __init__(self, cartodbUser, apiKey, multiuser=False, hostname='carto.com'):
QObject.__init__(self)
self.multiuser = multiuser
self.apiKey = apiKey
Expand Down
2 changes: 1 addition & 1 deletion pylintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[MASTER]
extension-pkg-whitelist=PyQt4,qgis
extension-pkg-whitelist=PyQt4,qgis,QgisCartoDB

[BASIC]
# Good names for variables
Expand Down

0 comments on commit 07e3c5e

Please sign in to comment.