Work on native gui
This commit is contained in:
@@ -11,6 +11,7 @@ YMS Installation
|
|||||||
- mupdf-tools for extended pdf file management
|
- mupdf-tools for extended pdf file management
|
||||||
|
|
||||||
1.2 Native GUI
|
1.2 Native GUI
|
||||||
|
- python3-mysqldb
|
||||||
- Python GTK3
|
- Python GTK3
|
||||||
- python3-gi
|
- python3-gi
|
||||||
- gir1.2-gtk-3.0
|
- gir1.2-gtk-3.0
|
||||||
@@ -82,7 +83,16 @@ Configfile should be readable by webserver but not writeable.
|
|||||||
chmod 640 config.inc
|
chmod 640 config.inc
|
||||||
chgrp www-data config.inc
|
chgrp www-data config.inc
|
||||||
|
|
||||||
8. Start using YMS
|
8. Setup local GUI
|
||||||
|
|
||||||
|
Create a local database user with same name as your computer user and allow
|
||||||
|
database acces with current unix credentials:
|
||||||
|
mysql> CREATE USER 'ymsgui'@'localhost' IDENTIFIED BY 'geheim';
|
||||||
|
mysql> ALTER USER ymsgui@localhost IDENTIFIED VIA unix_socket;
|
||||||
|
|
||||||
|
Start ymdgui.py, default configuration file is automatically created
|
||||||
|
|
||||||
|
9. Start using YMS
|
||||||
|
|
||||||
Start your browser and login to YMS with the default username/password:
|
Start your browser and login to YMS with the default username/password:
|
||||||
captain/captain
|
captain/captain
|
||||||
|
|||||||
@@ -23,6 +23,21 @@ class Database():
|
|||||||
self.dcur = self.conn.cursor(MySQLdb.cursors.DictCursor)
|
self.dcur = self.conn.cursor(MySQLdb.cursors.DictCursor)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def connect_local(self):
|
||||||
|
# connection via local unix socket
|
||||||
|
if self.conn:
|
||||||
|
return True
|
||||||
|
MySQLdb.paramstyle = 'pyformat'
|
||||||
|
try:
|
||||||
|
self.conn = MySQLdb.connect(host='localhost', db=self.schema,
|
||||||
|
unix_socket='/run/mysqld/mysqld.sock', charset='utf8')
|
||||||
|
except MySQLdb.Error as e:
|
||||||
|
print(e)
|
||||||
|
return False
|
||||||
|
self.cur = self.conn.cursor()
|
||||||
|
self.dcur = self.conn.cursor(MySQLdb.cursors.DictCursor)
|
||||||
|
return True
|
||||||
|
|
||||||
def disconnect(self):
|
def disconnect(self):
|
||||||
self.cur.close()
|
self.cur.close()
|
||||||
self.dcur.close()
|
self.dcur.close()
|
||||||
|
|||||||
@@ -88,13 +88,24 @@ def messagebox(messagetext, symbol=None, title=None, parent=None):
|
|||||||
md.run()
|
md.run()
|
||||||
md.destroy()
|
md.destroy()
|
||||||
|
|
||||||
|
def create_config(cfgfile):
|
||||||
|
# create inital config file
|
||||||
|
with open(cfgfile, 'w') as fh:
|
||||||
|
fh.write('[DB]\n')
|
||||||
|
fh.write('host = localhost\n')
|
||||||
|
fh.write('db = yms\n')
|
||||||
|
fh.write('user = yms\n')
|
||||||
|
fh.write('pass = geheim\n')
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
locale.setlocale(locale.LC_ALL, '')
|
locale.setlocale(locale.LC_ALL, '')
|
||||||
gettext.bindtextdomain('ymsgui', 'locale')
|
gettext.bindtextdomain('ymsgui', 'locale')
|
||||||
gettext.textdomain('ymsgui')
|
gettext.textdomain('ymsgui')
|
||||||
_ = gettext.gettext
|
_ = gettext.gettext
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
if not config.read(os.path.expanduser(cfg['cfgfile'])):
|
cfgfile = os.path.expanduser(cfg['cfgfile'])
|
||||||
|
if not config.read(cfgfile):
|
||||||
|
create_config(cfgfile)
|
||||||
messagebox(_("Configuration file not found"), title="YMS")
|
messagebox(_("Configuration file not found"), title="YMS")
|
||||||
else:
|
else:
|
||||||
cfg['host'] = config.get('DB', 'host')
|
cfg['host'] = config.get('DB', 'host')
|
||||||
|
|||||||
Reference in New Issue
Block a user