Work on native gui design and install documentation
This commit is contained in:
@@ -66,6 +66,18 @@ Customize path and access rights to your needs
|
||||
chown -R www-data /var/local/yms
|
||||
chmod -R 750 /var/local/yms
|
||||
|
||||
To grant access for the local gui the directory has to be writeable by a special
|
||||
group (here as example 'yms'). The user which runs the local gui (here
|
||||
'guiuser') has also to be a member of that group as well as the webserver user
|
||||
''www-data'.
|
||||
|
||||
groupadd yms
|
||||
usermod -aG yms www-data
|
||||
usermod -aG yms guiuser
|
||||
chgrp yms /var/local/yms
|
||||
chgrp yms /var/local/yms/thumb
|
||||
chmod -R 770 /var/local/yms
|
||||
|
||||
5. Install webgui
|
||||
|
||||
5.1 Upload webgui files
|
||||
|
||||
+11
-2
@@ -8,6 +8,7 @@ class Database():
|
||||
self.conn = None
|
||||
self.cur = None
|
||||
self.dcur = None
|
||||
self.error = None
|
||||
|
||||
def connect(self, dbuser, dbpass):
|
||||
if self.conn:
|
||||
@@ -17,7 +18,7 @@ class Database():
|
||||
self.conn = MySQLdb.connect(host=self.hostname, db=self.schema,
|
||||
user=dbuser, passwd=dbpass, charset='utf8')
|
||||
except MySQLdb.Error as e:
|
||||
print(e)
|
||||
self.error = e
|
||||
return False
|
||||
self.cur = self.conn.cursor()
|
||||
self.dcur = self.conn.cursor(MySQLdb.cursors.DictCursor)
|
||||
@@ -32,7 +33,7 @@ class Database():
|
||||
self.conn = MySQLdb.connect(host='localhost', db=self.schema,
|
||||
unix_socket='/run/mysqld/mysqld.sock', charset='utf8')
|
||||
except MySQLdb.Error as e:
|
||||
print(e)
|
||||
self.error = e
|
||||
return False
|
||||
self.cur = self.conn.cursor()
|
||||
self.dcur = self.conn.cursor(MySQLdb.cursors.DictCursor)
|
||||
@@ -45,3 +46,11 @@ class Database():
|
||||
|
||||
def is_connected(self):
|
||||
return self.conn.open
|
||||
|
||||
def last_error(self):
|
||||
if not self.error:
|
||||
return(0, '')
|
||||
code = self.error.args[0]
|
||||
text = self.error.args[1]
|
||||
self.error = None
|
||||
return(code, text)
|
||||
|
||||
+2
-1
@@ -17,7 +17,8 @@ def init_named_controls(window, builder):
|
||||
'tbl': 'table',
|
||||
'mnu': 'menu',
|
||||
'img': 'image',
|
||||
'drw': 'area'
|
||||
'drw': 'area',
|
||||
'stk': 'stack'
|
||||
}
|
||||
for ctrl in ctrltype.values():
|
||||
setattr(window, ctrl, {})
|
||||
|
||||
+2030
-32
File diff suppressed because it is too large
Load Diff
@@ -2,6 +2,9 @@
|
||||
|
||||
"""
|
||||
|
||||
YMS native GUI.
|
||||
Runs as user SYSTEM with id=0
|
||||
|
||||
Configuration file located at ~/.config/ymsgui.conf:
|
||||
[DB]
|
||||
host = localhost
|
||||
@@ -31,7 +34,8 @@ cfg = {
|
||||
'cfgfile': '~/.config/ymsgui.conf',
|
||||
'host': 'localhost',
|
||||
'db': 'yms',
|
||||
'user': 'yms'
|
||||
'user': 'yms',
|
||||
'docpath': '/var/local/yms'
|
||||
}
|
||||
|
||||
class Frontend():
|
||||
@@ -73,13 +77,27 @@ class Frontend():
|
||||
Gtk.main()
|
||||
|
||||
def on_but_info_clicked(self, widget):
|
||||
|
||||
# Userlist
|
||||
sql = ("SELECT userid, login, displayname FROM user ORDER BY login")
|
||||
db.cur.execute(sql)
|
||||
for row in db.cur.fetchall():
|
||||
print(row)
|
||||
|
||||
def on_but_equip_detail_clicked(self, widget):
|
||||
self.stack['equipment'].set_visible_child(self.box['equip_detail'])
|
||||
|
||||
def on_but_equip_edit_clicked(self, widget):
|
||||
self.stack['equipment'].set_visible_child(self.box['equip_edit'])
|
||||
|
||||
def on_but_equip_save_clicked(self, widget):
|
||||
pass
|
||||
|
||||
def on_but_equip_cancel_clicked(self, widget):
|
||||
self.stack['equipment'].set_visible_child(self.box['equipment'])
|
||||
|
||||
def on_but_equip_cancel_clicked(self, widget):
|
||||
self.stack['equipment'].set_visible_child(self.box['equipment'])
|
||||
|
||||
def on_destroy(self, widget, data=None):
|
||||
Gtk.main_quit()
|
||||
|
||||
@@ -101,12 +119,14 @@ 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\n')
|
||||
fh.write('host = {}\n'.format(cfg['host']))
|
||||
fh.write('db = {}\n'.format(cfg['db']))
|
||||
fh.write('user = {}\n'.format(cfg['user']))
|
||||
fh.write('pass = changeme!\n\n')
|
||||
fh.write('[documents]\n')
|
||||
fh.write('basepath = /var/local/yms\n')
|
||||
fh.write('basepath = {}\n'.format(cfg['docpath']))
|
||||
# secure configuration
|
||||
os.chmod(cfgfile, 0o600)
|
||||
|
||||
if __name__ == "__main__":
|
||||
locale.setlocale(locale.LC_ALL, '')
|
||||
@@ -117,7 +137,11 @@ if __name__ == "__main__":
|
||||
cfgfile = os.path.expanduser(cfg['cfgfile'])
|
||||
if not config.read(cfgfile):
|
||||
create_config(cfgfile)
|
||||
messagebox(_("Configuration file not found"), title="YMS")
|
||||
messagebox(_("Configuration file '%s' not found.\n"
|
||||
"Default configuration has been created.\n"
|
||||
"Please edit that file according to your needs.\n\n"
|
||||
"Then restart this program."
|
||||
) % cfgfile, title="YMS")
|
||||
else:
|
||||
cfg['host'] = config.get('DB', 'host')
|
||||
cfg['db'] = config.get('DB', 'db')
|
||||
@@ -129,6 +153,10 @@ if __name__ == "__main__":
|
||||
app.run()
|
||||
db.disconnect()
|
||||
else:
|
||||
messagebox(_("Database connection cannot be established"), title="YMS")
|
||||
errno, errtxt = db.last_error()
|
||||
messagebox(_("Database connection cannot be established.\n\n"
|
||||
"Server: %s\nDatabase: %s\n"
|
||||
"Error: %s (%d)"
|
||||
) % (cfg['host'], cfg['db'], errtxt, errno), title="YMS")
|
||||
|
||||
# Another fine product of the sirius cybernetics corporation
|
||||
|
||||
Reference in New Issue
Block a user