Skip to content

Commit f79b744

Browse files
committed
Add check whether sqlanydb modul can be loaded
1 parent e6b45ac commit f79b744

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

geanypysql.py

+19-10
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,16 @@
33

44
import gtk
55
import geany
6-
import sqlanydb
6+
7+
8+
try:
9+
import sqlanydb
10+
sqla = True
11+
except:
12+
sqla = False
13+
14+
15+
716

817
class GeanyPySQLDB():
918

@@ -36,7 +45,7 @@ def connect(self):
3645
self.connection = sqlanydb.connect( userid=self.userid,
3746
password=self.password,
3847
server=self.server)
39-
48+
4049
def disconnect(self):
4150
if self.connection is not None:
4251
self.connection.close()
@@ -48,15 +57,15 @@ class GeanyPySQL(geany.Plugin):
4857
__plugin_version__ = "0.1"
4958
__plugin_description__ = "Making an SQL client out of Geany"
5059
__plugin_author__ = "Frank Lanitz <frank@frank.uvena.de>"
51-
60+
5261
db = None
5362
cursor = None
5463

5564
def __init__(self):
56-
57-
# Logging
65+
66+
# Logging
5867
geany.Plugin.__init__(self)
59-
68+
6069
# Adding menu entries
6170
# Add main menu entry for pluin and show it
6271
self.root_menu = gtk.MenuItem("_GeanyPySQL")
@@ -72,11 +81,11 @@ def __init__(self):
7281
# Now adding items to submenu
7382
mi_connect = gtk.MenuItem("_Connect")
7483
plugin_menu.append(mi_connect)
75-
84+
7685
mi_disconnect = gtk.MenuItem("_Disconnect")
7786
plugin_menu.append(mi_disconnect)
78-
79-
# And callbacks
87+
88+
# And callbacks
8089
mi_connect.connect("activate", self.on_click_connect, None)
8190
mi_disconnect.connect("activate", self.on_click_disconnect, None)
8291

@@ -88,7 +97,7 @@ def cleanup(self):
8897
def on_click_connect(self, widget, data):
8998
self.db = GPS_sqlanywhere(uid='dba', pwd='sql', server='foo')
9099
self.db.connect()
91-
100+
92101
def on_click_disconnect(self, widget, data):
93102
self.db.disconnect()
94103

0 commit comments

Comments
 (0)