diff --git a/CartoDBPlugin.py b/CartoDBPlugin.py index d4908be..ce7eb68 100644 --- a/CartoDBPlugin.py +++ b/CartoDBPlugin.py @@ -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 @@ -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 @@ -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")) @@ -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) @@ -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) diff --git a/cartodb/cartodb.py b/cartodb/cartodb.py index b768ed1..a1b1d15 100644 --- a/cartodb/cartodb.py +++ b/cartodb/cartodb.py @@ -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=''): @@ -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 @@ -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 diff --git a/cartodb/cartodbapi.py b/cartodb/cartodbapi.py index 745ccb0..1e50736 100644 --- a/cartodb/cartodbapi.py +++ b/cartodb/cartodbapi.py @@ -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 diff --git a/pylintrc b/pylintrc index b85e6a6..4990f1f 100644 --- a/pylintrc +++ b/pylintrc @@ -1,5 +1,5 @@ [MASTER] -extension-pkg-whitelist=PyQt4,qgis +extension-pkg-whitelist=PyQt4,qgis,QgisCartoDB [BASIC] # Good names for variables