Subversion Repositories basico

Compare Revisions

Ignore whitespace Rev 132 → Rev 133

/branches/BR-0.3/basico/webserver.py
36,8 → 36,8
self.thread = threading.Thread(target = self.webserver.serve_forever)
self.thread.daemon = True
self.thread.start()
self.log.debug("Basico WebServer Document Root: %s" % WEBROOT)
self.log.debug('Basico WebServer listening on port: {}'.format(self.webserver.server_port))
self.debug("Basico WebServer Document Root: %s" % WEBROOT)
self.debug('Basico WebServer listening on port: {}'.format(self.webserver.server_port))
 
 
def halt(self):
/branches/BR-0.3/basico/basico.py
37,10 → 37,8
from .callbacks import Callback
from .notify import Notification
from .workplace import Workplace
#~ from .dashboard import Dashboard
from .stats import Stats
from .database import Database
#~ from .webserver import WebServer
from .driver import SeleniumDriver
from .env import ROOT, APP, LPATH, GPATH, FILE, STATS
 
59,7 → 57,7
 
 
self.log = get_logger(self.__class__.__name__, FILE['LOG'])
self.log.info("Starting Basico")
self.debug("Starting Basico")
 
self.services = {}
try:
73,14 → 71,11
'Notify' : Notification(),
'Tasks' : Tasks(),
'IM' : IconManager(),
#~ 'Plugins' : Plugins(),
'Callbacks' : Callback(),
'Workplace' : Workplace(),
'Workplace' : Workplace(),
'Stats' : Stats(),
#~ 'Dashboard' : Dashboard(),
'DB' : Database(),
'Driver' : SeleniumDriver(),
#~ 'WebServer' : WebServer()
}
self.register_services(services)
except Exception as error:
87,6 → 82,8
self.log.error(error)
raise
 
def debug(self, message):
self.log.debug("%15s | %s" % (self.__class__.__name__, message))
 
def setup(self):
"""
95,30 → 92,11
https://docs.python.org/3/library/configparser.html#interpolation-of-values
https://docs.python.org/3/library/configparser.html#configparser.ConfigParser.optionxform
"""
self.log.debug("Setting up Basico environment")
self.log.debug("Global path: %s" % GPATH['ROOT'])
self.log.debug("Local path: %s" % LPATH['ROOT'])
self.debug("Setting up Basico environment")
self.debug("Global path: %s" % GPATH['ROOT'])
self.debug("Local path: %s" % LPATH['ROOT'])
 
#~ # Set up config
#~ CONFIG_FILE = self.get_file('CNF')
#~ self.config = SafeConfigParser(interpolation=ExtendedInterpolation())
#~ self.config.optionxform = str
 
#~ # Save config
#~ if not os.path.exists(CONFIG_FILE):
#~ self.log.debug('Configuration file not found. Creating a new one')
#~ with open(CONFIG_FILE, 'w') as configfile:
#~ self.config.write(configfile)
#~ self.log.info('Config file initialited')
 
 
#~ def get_config(self):
#~ CONFIG_FILE = self.get_file('CNF')
#~ self.config.read(CONFIG_FILE)
 
#~ return self.config
 
 
def get_file(self, name):
try:
return FILE[name]
192,7 → 170,7
"""
self.services[name].end()
self.services[name] = None
self.log.debug("Service %s stopped" % name)
self.debug("Service %s stopped" % name)
 
 
def check_gtk_version(self):
199,7 → 177,7
vmajor = Gtk.get_major_version()
vminor = Gtk.get_minor_version()
vmicro = Gtk.get_micro_version()
self.log.info("Found GTK+ Version: %d.%d.%d" % (vmajor, vminor, vmicro))
self.debug("Found GTK+ Version: %d.%d.%d" % (vmajor, vminor, vmicro))
 
if vmajor == 3 and vminor >= 18:
return True
215,7 → 193,7
driver = self.get_service('Driver')
 
# Show Selenium version
self.log.debug("Selenium version: %s" % selenium.__version__)
self.debug("Selenium version: %s" % selenium.__version__)
 
# Check proper GTK version
GTK_VERSION = uif.check_gtk_version()
226,7 → 204,7
run = GTK_VERSION and GECKO_DRIVER
 
if run:
self.log.info("Basico environment ready!")
self.debug("Basico environment ready!")
return True
else:
self.log.error("Error(s) found checking Basico environment")
250,7 → 228,7
self.log.error(self.get_traceback())
raise
 
self.log.info("Basico finished")
self.debug("Basico finished")
 
 
def get_traceback(self):
/branches/BR-0.3/basico/workplace.py
16,7 → 16,6
from gi.repository import Gio
from gi.repository import GLib
 
from .log import get_logger
from .sapnoteviewmenu import SAPNoteViewMenu
from .sapnoteviewvisor import SAPNoteViewVisor
from .service import Service
60,17 → 59,17
 
 
def show_import_dialog_launchpad(self, *args):
self.log.debug("Import from Launchpad")
self.debug("Import from Launchpad")
parent_window = self.gui.get_widget('mainwindow')
dialog = DlgImportFromLaunchpad(parent_window)
response = dialog.run()
 
if response == Gtk.ResponseType.OK:
self.log.debug("The OK button was clicked")
self.debug("The OK button was clicked")
lines = dialog.get_buffer()
self.cb.import_notes_from_sapnet(lines)
elif response == Gtk.ResponseType.CANCEL:
self.log.debug("The Cancel button was clicked")
self.debug("The Cancel button was clicked")
 
dialog.destroy()
 
77,17 → 76,7
 
def setup_widgets(self):
# Toolbar
#~ btnwpunfull = self.gui.get_widget('btnWPUnfullscreen')
#~ btnwpunfull.connect('clicked', self.uif.do_unfullscreen)
#~ imgwpunfull = self.gui.get_widget('imgWPUnfullscreen')
#~ icon = self.im.get_pixbuf_icon('unfullscreen', 24, 24)
#~ imgwpunfull.set_from_pixbuf(icon)
 
#~ icon = self.im.get_pixbuf_icon('addnote', 24, 24)
#~ imgwpaddnote = self.gui.get_widget('imgWPAddNote')
#~ imgwpaddnote.set_from_pixbuf(icon)
 
 
tgbshowmenu = self.gui.get_widget('tgbShowMenuView')
tgbshowmenu.connect('toggled', self.show_menu_view)
self.lblSelectedNotes = self.gui.get_widget('lblSelectedNotes')
103,10 → 92,6
visor = self.gui.add_widget('visor', SAPNoteViewVisor(self.app))
self.gui.swap_widget(visorbox, visor)
 
#~ toggled = visor.get_toggled()
#~ bag = visor.get_bag()
#~ label = self.gui.get_widget('lblSelectedNotes')
#~ label.set_markup('<b><small>%d</small>/%d of <big>%d</big></b>' % (len(toggled), len(bag), self.db.get_total()))
 
def get_services(self):
self.gui = self.app.get_service("GUI")
249,7 → 234,7
item = actions_menu.append_item(self.uif.create_item('Select All SAP Notes', 'app.actions-select-all', 'select-all'))
action_toggle = Gio.SimpleAction.new_stateful("actions-select-all", None, GLib.Variant.new_boolean(False))
action_toggle.connect("change-state", self.toggle_toggled)
self.log.debug(action_toggle)
self.debug(action_toggle)
app.add_action(action_toggle)
 
# MnuButton valid with any modern version of Gtk (?> 3.10)
260,9 → 245,6
 
 
def setup_menu_import(self):
#~ imgwpimport = self.gui.get_widget('imgWPImport')
#~ icon = self.im.get_pixbuf_icon('download', 24, 24)
#~ imgwpimport.set_from_pixbuf(icon)
viewmenu = self.gui.get_widget('viewmenu')
view = viewmenu.get_view()
 
/branches/BR-0.3/basico/callbacks.py
73,7 → 73,7
for sid in sapnotes:
url = SAP_NOTE_URL % sid
lurl.append(url)
self.log.debug("Browsing SAP Note %s" % sid)
self.debug("Browsing SAP Note %s" % sid)
self.utils.browse(lurl)
 
 
103,11 → 103,11
self.search_notes()
self.refresh_view()
self.alert.show('Delete', 'Selected SAP Notes deleted', 'information')
self.log.info("Selected SAP Notes deleted")
self.debug("Selected SAP Notes deleted")
db.save_notes()
elif response == Gtk.ResponseType.CANCEL:
self.alert.show('Delete', 'Delete action canceled by user', 'warning')
self.log.info("Delete action canceled by user")
self.debug("Delete action canceled by user")
 
dialog.destroy()
 
148,47 → 148,24
self.update_titlebar_title("Workbook", "comments")
 
 
#~ def show_search(self, *args):
#~ def reveal_search():
#~ revsearch = self.gui.get_widget('revSearch')
#~ tgbsearch = self.gui.get_widget('tgbSearch')
#~ if tgbsearch.get_active():
#~ revsearch.set_reveal_child(True)
#~ revsearch.set_no_show_all(False)
#~ revsearch.show_all()
#~ else:
#~ revsearch.set_reveal_child(False)
#~ revsearch.set_no_show_all(True)
#~ revsearch.hide()
 
#~ tgbsearch = self.gui.get_widget('tgbSearch')
#~ reveal_search()
#~ self.show_workplace()
 
 
def toggle_search(self, *args):
tgbsearch = self.gui.get_widget('tgbSearch')
toggled = tgbsearch.get_active()
tgbsearch.set_active(not toggled)
 
 
def show_help(self, *args):
notebook = self.gui.get_widget('mainbox')
notebook.set_current_page(5)
self.update_titlebar_title("Help", "basico_help")
 
 
def show_settings(self, button):
notebook = self.gui.get_widget('mainbox')
notebook.set_current_page(4)
self.update_titlebar_title("Settings", "settings")
 
#Toggle popover visibility
#~ if popover.get_visible():
#~ popover.hide()
#~ else:
#~ popover.show_all()
 
def show_popover(self, button, popover):
#Toggle popover visibility
if popover.get_visible():
popover.hide()
else:
196,7 → 173,6
 
 
def show_popover_menu(self, button, popover):
#Toggle popover visibility
if popover.get_visible():
popover.hide()
else:
211,12 → 187,6
 
 
def actions_manage_tasks(self, *args):
#~ sapnoteview = self.gui.get_widget('viewmenu')
#~ try:
#~ visor = self.gui.get_widget('visor')
#~ sapnotes = visor.get_toggled()
#~ except:
#~ sapnote = ''
self.tasks.show_window(active=True)
 
 
232,7 → 202,7
sapnoteview = self.gui.get_widget('viewmenu')
visor = self.gui.get_widget('visor')
sapnotes = visor.get_toggled()
self.log.debug("Action bookmark triggered for SAP Notes: %s" % sapnotes)
self.debug("Action bookmark triggered for SAP Notes: %s" % sapnotes)
view = sapnoteview.get_view()
self.sap.set_bookmark(sapnotes)
db.save_notes()
245,7 → 215,7
sapnoteview = self.gui.get_widget('viewmenu')
visor = self.gui.get_widget('visor')
sapnotes = visor.get_toggled()
self.log.debug("Action unbookmark triggered for SAP Notes: %s" % sapnotes)
self.debug("Action unbookmark triggered for SAP Notes: %s" % sapnotes)
self.sap.set_no_bookmark(sapnotes)
db.save_notes()
self.refresh_view(view='bookmarks')
282,7 → 252,7
 
for tid in sapnotes:
sid = "0"*(10 - len(tid)) + tid
self.log.debug("Exporting SAP Note %s to CSV file" % sid)
self.debug("Exporting SAP Note %s to CSV file" % sid)
csvrow = []
props = db.get_sapnote_metadata(sid)
 
294,10 → 264,10
csvrow.append(props[prop])
writer.writerow(csvrow)
self.alert.show('Export', 'Selected SAP Notes exported successfully to CSV format', 'information')
self.log.info("Selected SAP Notes exported to CSV format: %s" % export_path)
self.debug("Selected SAP Notes exported to CSV format: %s" % export_path)
else:
self.alert.show('Export', 'Export canceled by user', 'warning')
self.log.info("Export canceled by user")
self.debug("Export canceled by user")
dialog.destroy()
 
 
318,10 → 288,10
for sapnote in sapnotes:
fout.write("%s\n" % sapnote)
self.alert.show('Export', 'Selected SAP Notes exported successfully to TXT format', 'information')
self.log.info("Selected SAP Notes exported to TXT format: %s" % export_path)
self.debug("Selected SAP Notes exported to TXT format: %s" % export_path)
else:
self.alert.show('Export', 'Export canceled by user', 'warning')
self.log.info("Export canceled by user")
self.debug("Export canceled by user")
dialog.destroy()
 
 
348,46 → 318,17
target = export_path + SEP + 'basico-%s.json' % now.strftime("%Y%m%d_%H%M%S")
db.export_basico_package(bag, target)
self.alert.show('Export', 'Selected SAP Notes exported successfully to JSON format', 'information')
self.log.info("Selected SAP Notes exported to JSON: %s" % target)
self.debug("Selected SAP Notes exported to JSON: %s" % target)
else:
self.alert.show('Export', 'Export canceled by user', 'warning')
self.log.info("Export canceled by user")
self.debug("Export canceled by user")
dialog.destroy()
 
 
def actions_import_json(self, *args):
self.import_notes_from_file()
#~ db = self.get_service('DB')
#~ rootwin = self.gui.get_widget('mainwndow')
#~ sapnoteview = self.gui.get_widget('viewmenu')
#~ visor = self.gui.get_widget('visor')
#~ sapnotes = visor.get_toggled()
#~ dialog = Gtk.FileChooserDialog("Select Basico JSON file", rootwin,
#~ Gtk.FileChooserAction.OPEN,
#~ (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
#~ Gtk.STOCK_SAVE, Gtk.ResponseType.OK))
#~ response = dialog.run()
 
#~ if response == Gtk.ResponseType.OK:
#~ source = dialog.get_filename()
#~ try:
#~ with open(source, 'r') as fp:
#~ bag = json.load(fp)
#~ db.import(bag)
#~ self.log.debug ("Imported %d notes" % len(bag))
#~ except Exception as error:
#~ self.log.info("SAP Notes database not found. Creating a new one")
#~ self.save_notes()
 
#~ self.alert.show('Export', 'Selected SAP Notes exported successfully to JSON format', 'information')
#~ self.log.info("Selected SAP Notes exported to JSON: %s" % target)
#~ else:
#~ self.alert.show('Export', 'Export canceled by user', 'warning')
#~ self.log.info("Export canceled by user")
#~ dialog.destroy()
 
 
 
def actions_import_launchpad(self, *args):
self.show_addsapnotes_dialog()
 
415,8 → 356,8
except:
term = ''
 
self.log.debug("cmbvalue: %s" % cmbvalue)
self.log.debug("term: %s" % term)
self.debug("cmbvalue: %s" % cmbvalue)
self.debug("term: %s" % term)
 
visor = self.gui.get_widget('visor')
sapnotes = db.get_notes()
424,13 → 365,12
 
if len(term) == 0:
self.current_notes = found = sapnotes
self.log.debug("Found: %s" % len(found))
self.debug("Found: %s" % len(found))
visor.populate(found)
#~ viewmenu.collapse()
self.log.debug("--> Displaying all database")
self.debug("--> Displaying all database")
return
 
self.log.debug("Looking for '%s'" % term)
self.debug("Looking for '%s'" % term)
if cmbvalue == 'search':
for sid in sapnotes:
if term.upper() in sapnotes[sid]['title'].upper():
485,20 → 425,12
for sid in sapnotes:
if term in sid:
found[sid] = sapnotes[sid]
self.log.info("Term: '%s' (%d results)" % (term, len(found)))
self.debug("Term: '%s' (%d results)" % (term, len(found)))
self.current_notes = found
self.log.debug("Current Notes: %d" % len(self.current_notes))
self.debug("Current Notes: %d" % len(self.current_notes))
visor.populate(found)
 
 
#~ def import_notes(self, entry):
#~ ntbimport = self.gui.get_widget('ntbAddSAPNotes')
#~ imptype = ntbimport.get_current_page() # 0 -> Download, 1 -> Import from file
#~ if imptype == 0:
#~ self.import_notes_from_sapnet()
#~ elif imptype == 1:
#~ self.import_notes_from_file()
 
def import_notes(self, entry):
self.import_notes_from_sapnet()
 
506,9 → 438,6
def import_notes_from_file(self):
db = self.get_service('DB')
notebook = self.gui.get_widget('notebook')
#~ rootwin = self.gui.get_widget('mainbox')
#~ self.log.debug (type(rootwin))
 
dialog = Gtk.FileChooserDialog("Select Basico JSON file", None,
Gtk.FileChooserAction.OPEN,
(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
521,9 → 450,9
with open(source, 'r') as fp:
bag = json.load(fp)
db.import_sapnotes(bag)
self.log.info ("Imported %d notes from %s" % (len(bag), source))
self.debug ("Imported %d notes from %s" % (len(bag), source))
except Exception as error:
self.log.info("SAP Notes database not found. Creating a new one")
self.debug("SAP Notes database not found. Creating a new one")
self.save_notes()
sapnoteview = self.gui.get_widget('viewmenu')
self.current_notes = bag
531,12 → 460,9
db.save_notes()
self.refresh_view()
switch = self.gui.get_widget('schSelectNotesAllNone')
#~ sapnoteview.select_all_none(switch, True)
#~ sapnoteview.select_all_none(switch, False)
#~ sapnoteview.expand_all()
else:
self.alert.show('Import', 'Nothing imported', 'error')
self.log.debug("Nothing imported")
self.debug("Nothing imported")
dialog.destroy()
 
def import_notes_from_sapnet(self, lines):
547,11 → 473,6
winroot = self.gui.get_widget('mainwindow')
sapnotes = []
bag = set()
#~ txtnotes = self.gui.get_widget('txtSAPNotes')
#~ textbuffer = txtnotes.get_buffer()
#~ istart, iend = textbuffer.get_bounds()
#~ lines = textbuffer.get_text(istart, iend, False)
 
lines = lines.replace(' ', ',')
lines = lines.replace('\n', ',')
sapnotes.extend(lines.split(','))
560,7 → 481,7
if len(sapnote.strip()) > 0:
bag.add(sapnote.strip())
 
self.log.debug("%d SAP Notes to be downloaded: %s" % (len(bag), ', '.join(list(bag))))
self.debug("%d SAP Notes to be downloaded: %s" % (len(bag), ', '.join(list(bag))))
 
resnotes = {}
 
576,7 → 497,7
 
for job in jobs:
rc, sapnote = job.result()
self.log.debug("\tRC SAP Note %s: %s" % (sapnote, rc))
self.debug("\tRC SAP Note %s: %s" % (sapnote, rc))
resnotes[sapnote] = rc
time.sleep(0.2)
 
585,8 → 506,7
db.save_notes()
db.build_stats()
 
#~ textbuffer.set_text("")
self.log.info("Task completed.")
self.debug("Task completed.")
notebook.set_current_page(0)
dialog = Gtk.MessageDialog(winroot, 0, Gtk.MessageType.INFO, Gtk.ButtonsType.OK, "Task completed")
msgrc = ""
613,7 → 533,6
 
sapnoteview = self.gui.get_widget('viewmenu')
self.current_notes = dlbag
#~ self.refresh_view()
self.refresh_and_clear_view()
sapnoteview.populate(dlbag)
sapnoteview.expand_all()
628,7 → 547,6
buffer.set_text("")
notebook.set_current_page(0)
self.refresh_view()
#~ self.alert.show('Download', 'Action canceled by user', 'warning')
boxMenu = self.gui.get_widget('boxMenu')
boxMenu.show_all()
self.refresh_and_clear_view()
635,25 → 553,20
 
 
def rebuild_database(self, *args):
self.log.debug("Rebuild database...")
self.debug("Rebuild database...")
 
db = self.get_service('DB')
CACHE_DIR = self.get_var('CACHE', 'local')
 
#~ FSAPNOTE = CACHE_DIR + sid + '.xml'
#~ if path is None:
#~ path = CACHE_DIR
 
files = glob.glob("%s%s*.xml" % (CACHE_DIR, SEP))
sap = self.app.get_service('SAP')
for filename in files:
self.log.debug("Filename: %s" % filename)
self.debug("Filename: %s" % filename)
sid = basename(filename)[0:-4]
self.log.debug("SAP Note Id: %s" % sid)
self.debug("SAP Note Id: %s" % sid)
 
valid = False
if db.is_stored(sid):
self.log.debug("\tSAP Note %s will be analyzed again" % sid)
self.debug("\tSAP Note %s will be analyzed again" % sid)
content = db.get_sapnote_content(sid)
sapnote = sap.analyze_sapnote_metadata(sid, content)
if len(sapnote) > 0:
665,37 → 578,24
self.refresh_view()
 
def refresh_and_clear_view(self, *args):
self.log.debug("Refresh & clear view ( I)")
self.debug("Refresh & clear view ( I)")
switch = self.gui.get_widget('schSelectNotesAllNone')
sapnoteview = self.gui.get_widget('viewmenu')
self.set_search_filter_key('search')
self.set_search_term('')
self.search_notes()
#~ self.refresh_view()
#~ sapnoteview.select_all_none(switch, False)
#~ sapnoteview.collapse()
 
 
def refresh_view(self, action=None, callback=None, view=None):
self.log.debug("Refresh & clear view (II)")
self.debug("Refresh & clear view (II)")
window = self.gui.get_widget('mainwindow')
viewmenu = self.gui.get_widget('viewmenu')
#~ switch_expand = self.gui.get_widget('schExpandCollapse')
#~ switch_select = self.gui.get_widget('schSelectNotesAllNone')
#~ active_ = switch.get_active()
 
if view is not None:
viewlabel = self.gui.get_widget('lblViewCurrent')
#~ name = "<span size='20000'><b>%-10s</b></span>" % view.capitalize()
name = "<b>%-10s</b>" % view.capitalize()
viewlabel.set_markup(name)
viewmenu.set_view(view)
#~ self.search_notes()
#~ switch_expand.set_active(True)
#~ switch_expand.set_active(False)
#~ switch_select.set_active(False)
#~ switch_select.set_active(True)
#~ switch_select.set_active(False)
 
 
def setup_dashboard(self):
721,17 → 621,9
 
self.config[self.section] = settings
self.save_config()
self.log.debug("Settings reverted to default")
self.debug("Settings reverted to default")
 
 
#~ def apply_preferences(self, *args):
#~ self.sap.apply_preferences()
#~ notebook = self.gui.get_widget('notebook')
#~ notebook.set_current_page(0)
#~ self.refresh_view(view='tasks')
#~ self.alert.show('Settings', 'SAP preferences saved', 'information')
 
 
def update_components_stats(self, *args):
statsviewer = self.gui.get_widget('scrStatsViewer')
view = WebKit.WebView()
756,16 → 648,12
tasks_selected = len(tasks.get_selected()) > 0
notes_selected = len(sapnoteview.get_selected_notes()) > 0
if tasks_selected and notes_selected:
#~ button.set_no_show_all(False)
#~ button.show_all()
button.set_sensitive(True)
self.log.debug("Task link button enabled")
self.debug("Task link button enabled")
else:
#~ button.hide()
#~ button.set_no_show_all(True)
button.set_sensitive(False)
self.log.debug("Task link button disabled")
self.debug("Task link button disabled")
 
 
def test(self, *args):
self.log.debug(args)
self.debug(args)
/branches/BR-0.3/basico/dashboard.py
79,12 → 79,12
def _visit_link(self, view, frame, request, action, policy):
# https://webkitgtk.org/reference/webkitgtk/stable/webkitgtk-webkitwebview.html#WebKitWebView-navigation-policy-decision-requested
link = request.get_uri()
self.log.debug(link)
self.debug(link)
if link.startswith('basico://'):
self.log.debug("Executing internal command")
self.debug("Executing internal command")
return True
else:
self.log.debug("Executing external link")
self.debug("Executing external link")
return False
 
 
/branches/BR-0.3/basico/data/ui/basico.ui
157,29 → 157,6
<property name="vexpand">False</property>
<property name="spacing">3</property>
<child>
<object class="GtkToggleButton" id="tgbShowMenuView2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="focus_on_click">False</property>
<property name="receives_default">True</property>
<property name="relief">none</property>
<property name="always_show_image">True</property>
<property name="active">True</property>
<child>
<object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-select-color</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box30">
<property name="visible">True</property>
<property name="can_focus">False</property>
230,7 → 207,7
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
<property name="position">1</property>
</packing>
</child>
</object>
/branches/BR-0.3/basico/database.py
7,13 → 7,8
 
import os
from os.path import basename
#~ import sys
#~ import time
import json
import glob
#~ import shutil
#~ import traceback
#~ from shutil import which
from cgi import escape
 
from .env import LPATH
35,8 → 30,7
self.stats['priority'] = set()
self.stats['type'] = set()
self.stats['version'] = set()
#~ self.stats['releaseon'] = set()
#~
#FIXME self.stats['releaseon'] = set()
 
 
def store(self, sapnote, html):
47,7 → 41,7
f = open(FSAPNOTE, 'w')
f.write(html)
f.close()
self.log.debug("\tSAP Note %s stored in %s" % (sapnote, FSAPNOTE))
self.debug("\tSAP Note %s stored in %s" % (sapnote, FSAPNOTE))
except Exception as error:
self.log.error(error)
 
56,7 → 50,6
db = self.get_service('DB')
CACHE_DIR = self.get_var('CACHE', 'local')
 
#~ FSAPNOTE = CACHE_DIR + sid + '.xml'
if path is None:
path = CACHE_DIR
 
63,13 → 56,13
files = glob.glob("%s%s*.xml" % (CACHE_DIR, SEP))
sap = self.app.get_service('SAP')
for filename in files:
self.log.debug("Filename: %s" % filename)
self.debug("Filename: %s" % filename)
sid = basename(filename)[0:-4]
self.log.debug("SAP Note Id: %s" % sid)
self.debug("SAP Note Id: %s" % sid)
 
valid = False
if db.is_stored(sid):
self.log.debug("\tSAP Note %s will be analyzed again" % sid)
self.debug("\tSAP Note %s will be analyzed again" % sid)
content = db.get_sapnote_content(sid)
sapnote = sap.analyze_sapnote_metadata(sid, content)
if len(sapnote) > 0:
93,7 → 86,6
CACHE_DIR = self.get_var('CACHE', 'local')
fsapnote = CACHE_DIR + sid + '.xml'
stored = os.path.exists(fsapnote)
#~ self.log.debug("\tSAP Note %s stored in database? %s" % (sid, stored))
 
return stored
 
106,19 → 98,17
alltasks = set()
 
for sid in bag:
# tasks
#COMMENT Tasks
try:
tasks = self.sapnotes[sid]['tasks']
for task in tasks:
alltasks.add(task)
except: pass
 
self.tasks = self.app.get_service('Tasks')
#~ self.tasks.save_tasks_from_stats(alltasks)
 
# components
#COMMENT Components
compkey = self.sapnotes[sid]['componentkey']
comptxt = self.sapnotes[sid]['componenttxt']
#~ self.log.debug("%s -> %s -> %s" % (sid, compkey, comptxt))
component = escape("%s (%s)" % (compkey, comptxt))
sep = compkey.find('-')
if sep > 0:
126,7 → 116,7
else:
maincomp = compkey
 
# categories
#COMMENT Categories
category = escape(self.sapnotes[sid]['category'])
try:
cont = self.stats['cats'][category]
134,8 → 124,8
except:
self.stats['cats'][category] = 1
 
# Build all (sub)keys from given component key
# useful for display stats with pygal
#COMMENT Build all (sub)keys from given component key
#COMMENT useful for display stats with pygal
compkeys = compkey.split('-')
total = len(compkeys)
key = ''
168,12 → 158,8
self.stats['priority'].add(priority)
self.stats['type'].add(ntype)
self.stats['version'].add(version)
#~ self.stats['releaseon'].add(releaseon)
#~ self.stats[''].add(version)
#~ self.log.debug(self.compstats)
#~ self.log.debug("==")
#~ self.log.debug(self.stats)
#~ self.log.debug(self.stats['maincomp'])
#FIXME self.stats['releaseon'].add(releaseon)
#FIXME self.stats[''].add(version)
 
 
def get_stats(self):
202,11 → 188,8
'''
Return a set of sapnotes which matches with an specific key/value
'''
#~ self.log.debug("Key: %s -> Value: %s" % (key, value))
 
bag = set()
sapnotes = self.get_notes()
#~ self.log.debug("%d SAP Notes to be analyzed" % len(sapnotes))
for sapnote in sapnotes:
if key.startswith('component') or \
key in ['category', 'priority', 'type']:
229,13 → 212,11
elif len(value) == 8:
value = value[0:4] + '-' + value[4:6] + '-' + value[6:8]
 
#~ self.log.debug("Date: %s" % value)
if sapnotes[sapnote]['feedupdate'].startswith(value):
bag.add(sapnote)
 
else:
pass
#~ self.log.debug(sapnotes[sapnote])
 
return bag
 
 
254,9 → 235,9
fnotes = self.get_file('SAP')
with open(fnotes, 'r') as fp:
self.sapnotes = json.load(fp)
self.log.debug ("Loaded %d notes" % len(self.sapnotes))
self.debug ("Loaded %d notes" % len(self.sapnotes))
except Exception as error:
self.log.info("SAP Notes database not found. Creating a new one")
self.debug("SAP Notes database not found. Creating a new one")
self.save_notes()
 
 
267,20 → 248,7
self.log.warning("SAP Note %s doesn't exist in the database" % sid)
return None
 
#~ def save_notes(self, filename='', bag={}):
#~ '''
#~ Save SAP Notes to file
#~ '''
#~ if len(filename) == 0:
#~ filename = self.get_file('SAP')
#~ bag = self.sapnotes
 
#~ fnotes = open(filename, 'w')
#~ json.dump(bag, fnotes)
#~ fnotes.close()
#~ self.log.info ("Saved %d notes to %s" % (len(bag), filename))
 
 
def save_notes(self, bag={}, export_path=None):
'''
Save SAP Notes to json database file
294,7 → 262,7
fdb = open(export_path, 'w')
json.dump(bag, fdb)
fdb.close()
self.log.info ("Saved %d notes to %s" % (len(bag), export_path))
self.debug ("Saved %d notes to %s" % (len(bag), export_path))
 
 
def export(self, bag, export_path=None):
303,33 → 271,8
 
def export_basico_package(self, bag, target):
self.save_notes(bag, target)
#~ TMP_DIR = LPATH['TMP']
#~ PKG_DIR = TMP_DIR + 'basico'
#~ BCO_SAPNOTES = PKG_DIR + SEP + 'sapnotes.json'
#~ TARGET = export_path + SEP + '.bco'
 
# 0 Delete temporary package dir
#~ try:
#~ shutil.rmtree(PKG_DIR)
#~ self.log.debug("Temporary package dir deleted: '%s'" % PKG_DIR)
#~ except: pass
 
# 1 Create temporary dir for building a basico package
#~ os.mkdir(PKG_DIR)
#~ self.log.debug("Temporary package dir created: '%s'" % PKG_DIR)
 
# 2 Export selected SAP Notes to basico package directory
#~ self.save_notes(bag, BCO_SAPNOTES)
 
# 3 Create Basico Package
#~ utils = self.get_service('Utils')
#~ utils.zip('basico_package', PKG_DIR)
 
# 4 Delete temporary dir
#~ shutil.rmtree(PKG_DIR)
#~ self.log.debug("Temporary package dir deleted: '%s'" % PKG_DIR)
 
 
def get_property_count(self, prop):
found = 0
 
358,7 → 301,7
tasks = self.sapnotes[sapnote]['tasks']
except Exception as error:
tasks = []
self.log.debug("Tasks: %s" % tasks)
self.debug("Tasks: %s" % tasks)
return tasks
 
 
366,7 → 309,7
for sapnote in sapnotes:
try:
self.sapnotes[sapnote]['tasks'] = tasks
self.log.info("Linked SAP Note %s to task(s): %s" % (sapnote, tasks) )
self.debug("Linked SAP Note %s to task(s): %s" % (sapnote, tasks) )
except:
self.log.error(self.get_traceback())
 
393,7 → 336,7
def set_bookmark(self, lsid):
for sid in lsid:
self.sapnotes[sid]['bookmark'] = True
self.log.info("SAP Note %s bookmarked: True" % sid)
self.debug("SAP Note %s bookmarked: True" % sid)
self.save_notes()
 
 
400,7 → 343,7
def set_no_bookmark(self, lsid):
for sid in lsid:
self.sapnotes[sid]['bookmark'] = False
self.log.info("SAP Note %s bookmarked: False" % sid)
self.debug("SAP Note %s bookmarked: False" % sid)
self.save_notes()
 
 
/branches/BR-0.3/basico/driver.py
48,7 → 48,7
FIREFOX_PROFILE = webdriver.FirefoxProfile(FIREFOX_PROFILE_DIR)
driver = webdriver.Firefox(FIREFOX_PROFILE)
self.driver = driver
self.log.debug("Webdriver initialited")
self.debug("Webdriver initialited")
 
return self.driver
 
56,9 → 56,9
def close(self):
try:
self.driver.quit()
self.log.debug("\tWebdriver closed")
self.debug("\tWebdriver closed")
except:
self.log.debug("Webdriver already closed")
self.debug("Webdriver already closed")
pass
 
self.driver = None
92,7 → 92,7
GECKODRIVER = utils.which('geckodriver')
 
if not GECKODRIVER:
self.log.debug("Attempting to download Gecko driver and install it.")
self.debug("Attempting to download Gecko driver and install it.")
utils.install_geckodriver()
 
GECKODRIVER = utils.which('geckodriver')
100,7 → 100,7
self.log.warning("Gecko driver not found.")
return False
else:
self.log.debug("Gecko Webdriver found in: %s" % GECKODRIVER)
self.debug("Gecko Webdriver found in: %s" % GECKODRIVER)
return True
 
 
/branches/BR-0.3/basico/env.py
64,9 → 64,3
 
# APP STATS
STATS = {}
 
# SAP related
#~ SAP = {}
#~ SAP['NOTE_URL'] = "https://launchpad.support.sap.com/#/notes/%s"
#~ SAP['ODATA_NOTE_URL'] = "https://launchpad.support.sap.com/services/odata/svt/snogwscorr/TrunkSet(SapNotesNumber='%s',Version='0',Language='E')" #$expand=LongText" #?$expand=LongText,RefTo,RefBy"
 
/branches/BR-0.3/basico/gui.py
46,15 → 46,13
'''
Let GUI service start
'''
self.log.debug("Setting up GUI")
#~ Gdk.threads_init()
 
self.debug("Setting up GUI")
GObject.threads_init()
self.sap.run()
self.ui = UIApp(self.app)
DEBUG_END_TIME = datetime.now()
STATS['BASICO_STARTUP_END'] = datetime.now()
self.log.debug("Startup duration: %s" % (STATS['BASICO_STARTUP_END'] - STATS['BASICO_STARTUP_START']))
self.debug("Startup duration: %s" % (STATS['BASICO_STARTUP_END'] - STATS['BASICO_STARTUP_START']))
self.ui.run()
 
 
69,7 → 67,7
'''
End GUI Service
'''
self.log.debug("GUI terminated")
self.debug("GUI terminated")
self.ui.quit()
 
 
/branches/BR-0.3/basico/iconmanager.py
41,12 → 41,9
# Get icon from cache if exists or add a new one
try:
icon = self.icondict[key]
#~ print ("ICON TRY: %s: %s" % (type(icon), icon))
except:
#~ OLD WAY: icon = Pixbuf.new_from_file_at_scale(icon_name, width, height, True)
iconinfo = self.theme.lookup_icon(name, width, Gtk.IconLookupFlags.GENERIC_FALLBACK)
icon = iconinfo.load_icon()
#~ print ("ICON EXCEPT: %s: %s" % (type(icon), icon))
self.icondict[key] = icon
 
return icon
/branches/BR-0.3/basico/log.py
17,16 → 17,16
log.setLevel(logging.DEBUG)
 
## Redirect log to stdout
formatter = logging.Formatter("%(levelname)7s | %(lineno)4d |%(name)15s | %(asctime)s | %(message)s")
formatter = logging.Formatter("%(levelname)7s | %(lineno)3d | %(asctime)s | %(message)s")
ch = logging.StreamHandler() # Create console handler and set level to debug
ch.setLevel(logging.DEBUG) # Set logging devel
ch.setFormatter(formatter) # add formatter to console handler
log.addHandler(ch) # add console handler to logger
 
# Redirect log to file
#~ fh = logging.FileHandler(LOG_FILE)
#~ fh.setFormatter(formatter)
#~ fh.setLevel(logging.DEBUG) # Set logging devel
#~ log.addHandler(fh) # add file handler to logger
#FIXME Redirect log to file
#FIXME fh = logging.FileHandler(LOG_FILE)
#FIXME fh.setFormatter(formatter)
#FIXME fh.setLevel(logging.DEBUG) # Set logging devel
#FIXME log.addHandler(fh) # add file handler to logger
 
return log
/branches/BR-0.3/basico/menus.py
59,26 → 59,8
 
def create_popup_menu_by_sapnote(self, sid):
return None
#~ db = self.get_service('DB')
#~ sapnote = db.get_sapnote_metadata(sid)
#~ sapnoteview = self.gui.get_widget('viewmenu')
#~ component = sapnote['componentkey']
#~ category = sapnote['category']
#~ ICONS_DIR = self.get_var('ICONS')
 
#~ menu = Gtk.Menu()
 
#~ item = Gtk.ImageMenuItem()
#~ icon = self.im.get_image_icon('component', 24, 24)
#~ item.set_image(icon)
#~ item.set_always_show_image(True)
#~ item.set_label("Select all SAP Notes with component %s" % component)
#~ item.connect("activate", self.select_by_component, component, True)
#~ menu.append(item)
 
#~ return menu
 
 
def create_popup_menu_by_component(self, component):
menu = Gtk.Menu()
ICONS_DIR = self.get_var('ICONS')
/branches/BR-0.3/basico/plugins.py
44,7 → 44,7
 
def rebuild_plugins(self):
DIR_PLUGINS = self.get_var('PLUGINS', 'local')
self.log.debug("Looking for plugins in: %s" % DIR_PLUGINS)
self.debug("Looking for plugins in: %s" % DIR_PLUGINS)
for plugindir in os.listdir(DIR_PLUGINS):
setupdir = DIR_PLUGINS + '/' + plugindir
setupfile = DIR_PLUGINS + '/' + plugindir + '/setup.py'
52,7 → 52,7
cmd = "cd %s; python3 %s develop --install-dir .. -m > /dev/null 2>&1" % (setupdir, setupfile)
exitstatus = os.system(cmd)
#~ (exitstatus, outtext) = commands.getstatusoutput(cmd)
self.log.debug(exitstatus)
self.debug(exitstatus)
if exitstatus != 0:
self.log.warning( "Plugin '%s' not available. Error: %d" % (plugindir, exitstatus) )
#~ self.log.warning( outtext )
89,7 → 89,7
self.log.warning( "Hook '%s': %s" % (name, error))
raise
 
self.log.debug("Plugin system initialited: %d plugins loaded" % loaded)
self.debug("Plugin system initialited: %d plugins loaded" % loaded)
return plugins
 
 
/branches/BR-0.3/basico/projects.py
87,7 → 87,7
if result: #result could be None
model, iter = result
project = model.get_value(iter, 1)
self.log.debug(project)
self.debug(project)
sapnotes = db.get_notes()
for sapnote in sapnotes:
projects = sapnotes[sapnote]['projects']
94,7 → 94,7
if project in projects:
found += 1
if found > 1:
self.log.debug("Project %s is still assigned to other SAP Notes" % project)
self.debug("Project %s is still assigned to other SAP Notes" % project)
head = "Project could not be deleted"
body = "Project %s is still assigned to other SAP Notes" % project
self.uif.message_dialog(head , body)
127,13 → 127,6
self.window.set_no_show_all(False)
self.window.show_all()
 
#~ if sapnote is not None:
#~ projects = self.sap.get_linked_projects(sapnote)
#~ self.log.debug("Projects for SAP Note %s: %s" % (sapnote, projects))
#~ dialog = Gtk.MessageDialog(self.parent, 0, Gtk.MessageType.INFO, Gtk.ButtonsType.OK, "Task completed")
#~ dialog.format_secondary_text("All SAP Notes were downloaded sucessfully.")
#~ dialog.run()
#~ dialog.destroy()
 
def hide_window(self, *args):
self.window.set_no_show_all(True)
195,8 → 188,8
 
sapnotes.sort()
projects.sort()
self.log.debug('SAP Notes: %s' % sapnotes)
self.log.debug(' Projects: %s' % projects)
self.debug('SAP Notes: %s' % sapnotes)
self.debug(' Projects: %s' % projects)
self.sap.link_to_project(sapnotes, projects)
sapnoteview = self.gui.get_widget('viewmenu')
sapnoteview.refresh()
224,7 → 217,7
if len(project) > 0:
if len(sapnote) > 0:
snprjs = self.sap.get_linked_projects(sapnote)
self.log.debug(snprjs)
self.debug(snprjs)
if project in snprjs:
model.append([True, project])
else:
/branches/BR-0.3/basico/sap.py
90,7 → 90,6
'''
Get metadata details from SAP Note
'''
#~ self.log.debug("\t%s" % content)
try:
utils = self.get_service('Utils')
f = utils.feedparser_parse(content)
111,11 → 110,10
sapnote['version'] = f.entries[0].d_version_detail['value']
sapnote['feedupdate'] = f.entries[0].updated
sapnote['bookmark'] = False
self.log.info ("\tSAP Note %s analyzed successfully" % sid)
self.debug ("\tSAP Note %s analyzed successfully" % sid)
except Exception as error:
sapnote = {}
self.log.error("\tError while analyzing data for SAP Note %s" % sid)
#~ self.log.error("\t%s" % error)
 
return sapnote
 
123,17 → 121,16
def fetch(self, sid):
db = self.get_service('DB')
valid = False
#~ self.log.debug("%3d/%3d - Fetching SAP Note %s" % (self.notes_fetched+1, self.notes_total, sid))
 
if not db.is_stored(sid):
self.log.debug("%3d/%3d - SAP Note %s must be downloaded" % (self.notes_fetched+1, self.notes_total, sid))
self.debug("%3d/%3d - SAP Note %s must be downloaded" % (self.notes_fetched+1, self.notes_total, sid))
content = self.download(sid)
if len(content) > 0:
self.log.debug("%3d/%3d - SAP Note %s fetched" % (self.notes_fetched+1, self.notes_total, sid))
self.debug("%3d/%3d - SAP Note %s fetched" % (self.notes_fetched+1, self.notes_total, sid))
else:
self.log.debug("%3d/%3d - SAP Note %s not feched" % (self.notes_fetched+1, self.notes_total, sid))
self.debug("%3d/%3d - SAP Note %s not feched" % (self.notes_fetched+1, self.notes_total, sid))
else:
self.log.debug("%3d/%3d - SAP Note %s will be analyzed again" % (self.notes_fetched+1, self.notes_total, sid))
self.debug("%3d/%3d - SAP Note %s will be analyzed again" % (self.notes_fetched+1, self.notes_total, sid))
content = db.get_sapnote_content(sid)
 
self.fetched()
148,21 → 145,6
return valid, sid
 
 
 
#~ def apply_preferences(self, *args):
#~ self.gui = self.app.get_service('GUI')
#~ settings = self.get_default_settings()
#~ new_settings = {}
#~ for key in settings:
#~ widget = self.gui.get_widget(key)
#~ value = widget.get_text()
#~ new_settings[key] = value
#~ self.log.debug(new_settings)
#~ self.config[self.section] = new_settings
#~ self.save_config()
#~ self.log.debug("Settings saved")
 
 
def start_fetching(self, total):
self.notes_fetched = 0
self.notes_total = total
180,23 → 162,11
def download(self, sapnote=None):
try:
driver = self.get_service('Driver')
#~ browser = driver.open()
#~ self.log.debug("\tDownloading SAP Note %s:" % sapnote)
#~ self.log.debug(ODATA_NOTE_URL % sapnote)
ODATA_NOTE_URL = self.settings.get('SAP', 'ODATA_NOTE_URL')
browser = driver.load(ODATA_NOTE_URL % sapnote)
time.sleep(10)
content = browser.page_source
#~ browser = driver.load(ODATA_NOTE_URL_LONGTEXT % sapnote)
#~ time.sleep(10)
#~ longtext = browser.page_source
#~ self.log.debug(longtext)
 
#~ self.log.debug("\t%3d - SAP Note %s downloaded" % (sapnote, driver.)
#~ else:
#~ content = ''
except Exception as error:
#~ self.log.error("\tSAP Note %s coud not be downloaded" % sapnote)
self.log.error(error)
content = ''
 
217,13 → 187,13
tasks = self.sapnotes[sapnote]['tasks']
except Exception as error:
tasks = []
self.log.debug("Tasks: %s" % tasks)
self.debug("Tasks: %s" % tasks)
return tasks
 
 
def link_to_task(self, sapnotes, tasks):
if len(sapnotes) == 0:
self.log.debug("No SAP Notes selected. No task will be linked.")
self.debug("No SAP Notes selected. No task will be linked.")
return
 
db = self.get_service('DB')
232,7 → 202,7
for tid in sapnotes:
sid = "0"*(10 - len(tid)) + tid
store[sid]['tasks'] = tasks
self.log.info("Linked SAP Note %s to task(s): %s" % (sid, tasks) )
self.debug("Linked SAP Note %s to task(s): %s" % (sid, tasks) )
 
 
def set_bookmark(self, bag):
243,7 → 213,7
sid = "0"*(10 - len(tid)) + tid
sapnotes[sid]['bookmark'] = True
mylist.append(sapnotes[sid])
self.log.info("SAP Note %s bookmarked" % sid)
self.debug("SAP Note %s bookmarked" % sid)
db.add_list(mylist)
 
 
255,7 → 225,7
sid = "0"*(10 - len(tid)) + tid
sapnotes[sid]['bookmark'] = False
mylist.append(sapnotes[sid])
self.log.info("SAP Note %s unbookmarked" % sid)
self.debug("SAP Note %s unbookmarked" % sid)
db.add_list(mylist)
 
 
/branches/BR-0.3/basico/sapnoteview.py
3,7 → 3,7
# File: sapnoteview.py
# Author: Tomás Vírseda
# License: GPL v3
# Description: SAPNoteView GTK.TreeView widgets
# Description: SAPNoteView GTK.TreeView widget
 
from enum import IntEnum
import traceback as tb
21,11 → 21,7
from datetime import datetime
from dateutil import parser as dateparser
 
from .log import get_logger
 
 
#~ Enum(value='Column', names=<...>, *, module='...', qualname='...', type=<mixed-in class>, start=1)
 
class Column(IntEnum):
rowtype = 0
checkbox = 1
45,9 → 41,6
def __init__(self, app):
SAPNoteView.numOfInstances += 1
self.app = app
LOG_FILE = self.app.get_file('LOG')
LOG_NAME = self.__class__.__name__
self.log = get_logger(LOG_NAME, LOG_FILE)
self.get_services()
self.toggled = 0
self.selected = set()
237,7 → 230,7
 
 
def getNumInstances(self):
self.log.debug("SAPNoteView instances: %d" % self.numOfInstances)
self.app.debug("SAPNoteView instances: %d" % self.numOfInstances)
 
 
def get_services(self):
/branches/BR-0.3/basico/sapnoteviewmenu.py
3,7 → 3,7
# File: sapnoteviewmenu.py
# Author: Tomás Vírseda
# License: GPL v3
# Description: SAPNoteView GTK.TreeView widgets
# Description: SAPNoteViewMenu Widget
 
from enum import IntEnum
import traceback as tb
21,12 → 21,11
from datetime import datetime
from dateutil import parser as dateparser
 
from .service import Service
from .sapnoteview import SAPNoteView
from .log import get_logger
 
 
 
class SAPNoteViewMenu(SAPNoteView):
class SAPNoteViewMenu(SAPNoteView, Service):
def prepare(self):
self.column_rowtype.set_visible(False)
self.column_checkbox.set_visible(False)
46,48 → 45,26
self.set_hover_selection(False)
self.set_grid_lines(Gtk.TreeViewGridLines.NONE)
self.set_level_indentation(0)
#~ self.set_search_entry(self.gui.get_widget('stySearchInfo'))
#~ self.set_search_column(3)
 
# Go live
# FIXME: right click not working
#~ self.connect('button_press_event', self.right_click)
#~ self.connect('row-activated', self.double_click)
#~ self.connect('cursor-changed', self.row_changed)
self.sig_selection_changed = self.selection.connect('changed', self.row_changed) #self.selection_changed)
 
 
#~ def selection_changed(self, *args):
#~ self.log.debug(args)
#~ return True
 
 
def row_changed(self, selection):
#~ self.log.debug("Status: %s" % self.current_status)
if self.current_status is None:
#~ pass
selected = set()
#~ selection = treeview.get_selection()
model, treeiters = selection.get_selected() #_rows()
#~ self.log.debug("%s - %s - %s" % (model, selection, treeiters))
visor = self.gui.get_widget('visor')
try:
row = model[treeiters][0]
row_type, sid = row.split('@')
self.log.debug("%s (%s)" % (row_type, sid))
self.debug("%s (%s)" % (row_type, sid))
matches = self.db.get_notes_by_node(row_type, sid)
#~ self.log.debug("Populating visor with %d SAP Notes" % len(matches))
visor.populate(matches)
except:
#~ self.log.error(tb.format_exc())
#~ pass
visor.populate([])
 
#~ return False
 
 
def right_click(self, treeview, event, data=None):
self.log.debug("Right click intercepted")
self.debug("Right click intercepted")
if event.button == 3:
x = int(event.x)
y = int(event.y)
101,9 → 78,9
model = treeview.get_model()
treeiter = model.get_iter(path)
for n in range(9):
self.log.debug("%d -> %s" % (n, model.get_value(treeiter, n)))
self.debug("%d -> %s" % (n, model.get_value(treeiter, n)))
rowtype, value = model.get_value(treeiter, 0).split('@')
self.log.debug("Row type: %s -> %s" % (rowtype, value))
self.debug("Row type: %s -> %s" % (rowtype, value))
if rowtype == 'task':
task = model.get_value(treeiter, 6)
self.popup_menu = self.menu.create_popup_menu_by_task(task)
137,12 → 114,12
# Change icon
if view is None:
view ='chronologic'
self.log.debug ("View: %s - Type (%s)" % (view, type(view)))
self.debug ("View: %s - Type (%s)" % (view, type(view)))
iconview = self.gui.get_widget('imgViewCurrent')
icon = self.im.get_pixbuf_icon(view, 16, 16)
iconview.set_from_pixbuf(icon)
self.view = view
self.log.debug("Set current view to: %s" % view)
self.debug("Set current view to: %s" % view)
 
# Change label
viewlabel = self.gui.get_widget('lblViewCurrent')
155,7 → 132,6
return self.view
 
def populate(self, sapnotes):
#~ self.log.debug(self.sig_selection_changed)
self.current_status = "working"
 
self.set_headers_visible(False)
168,7 → 144,7
tgbshowmenu = self.gui.get_widget('tgbShowMenuView')
tgbshowmenu.set_active(True)
 
self.log.debug("sapnotes: %s" % sapnotes)
self.debug("sapnotes: %s" % sapnotes)
if len(sapnotes) == 0:
sapnotes = self.db.get_notes()
 
195,7 → 171,7
else:
self.populate_by_components(sapnotes)
 
self.log.debug("View '%s' populated" % (self.view))
self.debug("View '%s' populated" % (self.view))
self.current_status = None
 
 
215,7 → 191,7
 
 
def populate_by_components(self, sapnotes, only_bookmarks=False):
self.log.debug('Populating by components')
self.debug('Populating by components')
self.model.clear()
self.treepids = {}
self.column_component.set_title('Components')
256,11 → 232,7
ppid = self.model.append(ppid, node)
self.treepids[key] = ppid
 
#~ for sid in sapnotes:
#~ compkey = escape(sapnotes[sid]['componentkey'])
#~ pid = self.treepids[compkey]
 
 
def populate_by_tasks(self, sapnotes):
self.model.clear()
treepids = {}
283,7 → 255,7
if len(sapnotes) == 0:
return
 
#~ "No task assigned" node creation
#COMMENT: "No task assigned" node creation
node = self.get_node_task('', icon_notask)
pid = self.model.append(None, node)
treepids['None'] = pid
355,13 → 327,7
pid = self.model.append(None, node)
treepids[priority] = pid
 
#~ for sid in sapnotes:
#~ priority = sapnotes[sid]['priority']
#~ pid = treepids[priority]
#~ sapnote = self.get_node_sapnote(sapnotes[sid], sid)
#~ self.model.append(pid, sapnote)
 
 
def populate_by_type(self, sapnotes):
self.model.clear()
treepids = {}
399,11 → 365,6
pid = self.model.append(None, node)
treepids[sntype] = pid
 
#~ for sid in sapnotes:
#~ sntype = sapnotes[sid]['type']
#~ pid = treepids[sntype]
#~ sapnote = self.get_node_sapnote_type(sapnotes[sid], sid)
#~ self.model.append(pid, sapnote)
 
def get_node_component(self, compkey, comptxt):
icon = self.im.get_icon('component', 32, 32)
421,7 → 382,7
node.append("") # Title
node.append("") # Priority
node.append("") # Lang
#~ node.append("") # Version
#FIXME node.append("") # Version
node.append("") # Release on
return node
 
444,13 → 405,13
node.append("") # Title
node.append("") # Priority
node.append("") # Lang
#~ node.append("") # Version
#FIXME node.append("") # Version
node.append("") # Release on
return node
 
 
def populate_by_component_descriptions(self, sapnotes, only_bookmarks=False):
self.log.debug('Populating by components')
self.debug('Populating by components')
self.model.clear()
self.treepids = {}
self.column_component.set_title('Components')
533,13 → 494,7
pid = self.model.append(None, node)
treepids[cat] = pid
 
#~ for sid in sapnotes:
#~ category = sapnotes[sid]['category']
#~ pid = treepids[category]
#~ sapnote = self.get_node_sapnote_category(sapnotes[sid], sid)
#~ self.model.append(pid, sapnote)
 
 
def populate_by_chronologic(self, sapnotes):
self.model.clear()
treepids = {}
611,17 → 566,6
node = self.get_node_date_day(downloaded, key_day)
treepids[key_day] = self.model.append(treepids[key_month], node)
 
#~ for sid in sapnotes:
#~ downloaded = dateparser.parse(sapnotes[sid]['feedupdate'])
#~ year = "%d" % downloaded.year
#~ month = "%02d" % downloaded.month
#~ day = "%02d" % downloaded.day
#~ key_year = year
#~ key_month = year + month
#~ key_day = year + month + day
#~ node = self.get_node_sapnote_chronologic(sapnotes[sid], sid)
#~ self.log.debug("KeyDay %s for SAP Note %s" % (treepids[key_day], sid))
#~ self.model.append(treepids[key_day], node)
 
def get_node_category(self, sapnote):
compkey = escape(sapnote['componentkey'])
630,10 → 574,8
icon = self.im.get_icon('category', 32, 32)
 
if len(catname) == 0:
#~ catname = "<span size='12000'><b>No category assigned</b></span>"
catname = "No category assigned"
else:
#~ category = "<span size='15000'><b>%s</b></span>" % catname
category = "%s" % catname
 
node = []
647,7 → 589,7
node.append("") # Title
node.append("") # Priority
node.append("") # Lang
#~ node.append("") # Version
#FIXME node.append("") # Version
node.append("") # Release on
return node
 
666,7 → 608,7
node.append("") # Title
node.append("") # Priority
node.append("") # Lang
#~ node.append("") # Version
#FIXME node.append("") # Version
node.append("") # Release on
return node
 
685,7 → 627,7
node.append("") # Title
node.append("") # Priority
node.append("") # Lang
#~ node.append("") # Version
#FIXME node.append("") # Version
node.append("") # Release on
return node
 
704,7 → 646,7
node.append("") # Title
node.append("") # Priority
node.append("") # Lang
#~ node.append("") # Version
#FIXME node.append("") # Version
node.append("") # Release on
return node
 
728,7 → 670,7
node.append("") # Title
node.append("") # Priority
node.append("") # Lang
#~ node.append("") # Version
#FIXME node.append("") # Version
node.append("") # Release on
return node
 
773,7 → 715,7
node.append("") # Title
node.append("") # Priority
node.append("") # Lang
#~ node.append("") # Version
#FIXME node.append("") # Version
node.append("") # Release on
return node
 
797,7 → 739,7
node.append("") # Title
node.append("") # Priority
node.append("") # Lang
#~ node.append("") # Version
#FIXME node.append("") # Version
node.append("") # Release on
return node
 
822,9 → 764,9
node.append('sapnote@%s' % sid) # 0. # RowType
node.append(0) # 1. # CheckBox
node.append(icon) # 2. # Icon
#~ node.append(title) # 3. # Component
#FIXME node.append(title) # 3. # Component
node.append(compkey) # 3. # Component
self.log.debug("CompKey: %s" % compkey)
self.debug("CompKey: %s" % compkey)
node.append("") # 4. # Category
node.append(sapnote['type']) # 5. # Type
node.append("<b>%s</b>" %sid) # 6. # Sap Note ID
837,12 → 779,7
 
 
def get_node_sapnote_type(self, sapnote, sid):
#~ compkey = escape(sapnote['componentkey'])
#~ compkey = escape(sapnote['componentkey'])
#~ catname = escape(sapnote['category'])
sntype = "%s" % escape(sapnote['type'])
#~ released = dateparser.parse(sapnote['releaseon'])
#~ released = released.strftime("%Y.%m.%d")
sid = "0"*(10 - len(sid)) + sid
title = "%s" % (escape(sapnote['title']))
bookmarked = sapnote['bookmark']
/branches/BR-0.3/basico/sapnoteviewrow.py
3,7 → 3,7
# File: sapnoteviewrow.py
# Author: Tomás Vírseda
# License: GPL v3
# Description: SAPNoteView GTK.TreeView widgets
# Description: SAPNoteViewRow
 
from enum import IntEnum
import traceback as tb
21,16 → 21,11
from datetime import datetime
from dateutil import parser as dateparser
 
from .log import get_logger
 
 
class SAPNoteViewRow(Gtk.HBox):
def __init__(self, app, sid):
Gtk.HBox.__init__(self)
self.app = app
LOG_FILE = self.app.get_file('LOG')
LOG_NAME = self.__class__.__name__
self.log = get_logger(LOG_NAME, LOG_FILE)
self.get_services()
self.setup_row(sid)
 
66,9 → 61,7
self.revealer.set_reveal_child(not reveal)
self.revealer.set_visible(True)
 
#~ self.log.debug("Toggled rows: %d" % len(toggled))
 
 
def bookmark_switch(self, *args):
if self.bookmark.get_active():
icon = self.im.get_pixbuf_icon('bookmark_on', 16, 16)
225,12 → 218,8
vbox.pack_start(hboxdown, True, True, 0)
self.pack_start(vbox, True, True, 0)
self.show_all()
#~ self.log.debug("Adios")
 
#~ self.bookmark.get_style_context().add_class(Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION)
 
 
 
def get_node_sapnote(self, sid):
sapnotes = self.db.get_notes()
return sapnotes[sid]
/branches/BR-0.3/basico/sapnoteviewvisor.py
3,7 → 3,7
# File: sapnoteviewvisor.py
# Author: Tomás Vírseda
# License: GPL v3
# Description: SAPNoteView GTK.TreeView widgets
# Description: SAPNoteViewVisor widget
 
from enum import IntEnum
import traceback as tb
22,15 → 22,11
from dateutil import parser as dateparser
 
from .sapnoteviewrow import SAPNoteViewRow
from .log import get_logger
 
 
class SAPNoteViewVisor(Gtk.Box):
def __init__(self, app):
self.app = app
LOG_FILE = self.app.get_file('LOG')
LOG_NAME = self.__class__.__name__
self.log = get_logger(LOG_NAME, LOG_FILE)
self.get_services()
self.toggled = 0
self.selected = set()
185,7 → 181,6
if active:
sid = row.get_sid()
toggled.add(sid)
#~ self.log.debug("%s -> %s" % (row, active))
 
flowbox.foreach(foreach_row)
 
238,14 → 233,8
row = SAPNoteViewRow(self.app, sid)
flowbox.add(row)
 
#~ lblcount = self.gui.get_widget("lblSAPNoteViewCount")
#~ self.log.debug("lblcount: %s (%s)"% (str(lblcount), str(type(lblcount))))
#~ lblcount.set_markup("<span size=\"30000\">%d</span>" % len(bag))
self.gui.swap_widget(self, flowbox)
 
#~ toggled = self.get_toggled()
#~ lblSelectedNotes.set_markup('<b><small>%d</small>/%d of <big>%d</big></b>' % (len(toggled), len(bag), self.db.get_total()))
 
self.show_all()
 
 
/branches/BR-0.3/basico/service.py
8,7 → 8,6
import sys
import traceback as tb
 
from .log import get_logger
from .env import FILE
 
class Service(object):
35,7 → 34,7
 
 
def print_traceback(self):
self.log.error(tb.format_exc())
self.debug(tb.format_exc())
 
 
def start(self, app, logname=None):
49,17 → 48,14
"""
self.started = True
self.app = app
logfile = self.app.get_file('LOG')
self.log = get_logger(logname, logfile)
#~ self.config = self.app.get_config()
self.section = logname
self.init_section(self.section)
 
try:
self.initialize()
self.log.debug("Service %s loaded" % logname)
self.debug("Service %s loaded" % logname)
except Exception as error:
self.log.error (self.get_traceback())
self.debug (self.get_traceback())
 
 
def get_var(self, name, scope='global'):
82,7 → 78,7
try:
self.finalize()
except Exception as error:
self.log.error (self.get_traceback())
self.debug (self.get_traceback())
 
 
def initialize(self):
99,31 → 95,6
pass
 
 
#~ def get_config_value(self, key):
#~ """Get value for a given param in section for this service
#~ @type param: string
#~ @param param: parameter name
#~ """
#~ self.config = self.app.get_config()
#~ if self.config.has_section(self.section):
#~ if self.config.has_option(self.section, key):
#~ return self.config.get(self.section, key)
 
#~ return None
 
 
#~ def set_config_value(self, key, value):
#~ """Set value for a given param in section for this service
#~ @type param: string
#~ @param param: parameter name
#~ @type value: string
#~ @param param: new value for this parameter
#~ """
#~ self.config[self.section][key] = value
#~ self.log.debug("CONFIG[%s][%s] = %s" % (self.section, key, value))
#~ self.save_config()
 
 
def init_section(self, section):
"""Check if section exists in config. If not, create it"""
self.settings = self.app.get_service('Settings')
133,8 → 104,11
except:
config[section] = {}
self.settings.save(config)
self.log.debug("Section '%s' initialized in config file" % section)
self.debug("Section '%s' initialized in config file" % section)
 
def debug(self, message):
self.app.log.debug("%15s | %s" % (self.__class__.__name__, message))
 
def get_traceback(self):
return self.app.get_traceback()
 
/branches/BR-0.3/basico/settings.py
16,18 → 16,18
from .service import Service
from .env import FILE
 
#~ # Default settings for SAP module
#~ LOGIN_PAGE_URL = "https://accounts.sap.com"
#~ LOGOUT_PAGE_URL = "https://accounts.sap.com/ui/logout"
#~ ODATA_NOTE_URL = "https://launchpad.support.sap.com/services/odata/svt/snogwscorr/TrunkSet(SapNotesNumber='%s',Version='0',Language='E')" #$expand=LongText" #?$expand=LongText,RefTo,RefBy"
#~ SAP_NOTE_URL = "https://launchpad.support.sap.com/#/notes/%s"
#~ SAP_NOTE_URL_PDF = "https://launchpad.support.sap.com/services/pdf/notes/%s/E"
#~ TIMEOUT = 5
#COMMENT Default settings for SAP module
#COMMENT LOGIN_PAGE_URL = "https://accounts.sap.com"
#COMMENT LOGOUT_PAGE_URL = "https://accounts.sap.com/ui/logout"
#COMMENT ODATA_NOTE_URL = "https://launchpad.support.sap.com/services/odata/svt/snogwscorr/TrunkSet(SapNotesNumber='%s',Version='0',Language='E')" #$expand=LongText" #?$expand=LongText,RefTo,RefBy"
#COMMENT SAP_NOTE_URL = "https://launchpad.support.sap.com/#/notes/%s"
#COMMENT SAP_NOTE_URL_PDF = "https://launchpad.support.sap.com/services/pdf/notes/%s/E"
#COMMENT TIMEOUT = 5
 
 
class Settings(Service):
def initialize(self):
self.log.debug("Basico config file: %s" % FILE['CNF'])
self.debug("Basico config file: %s" % FILE['CNF'])
self.load()
 
def get(self, section, key):
34,10 → 34,10
config = self.load()
try:
value = config[section][key]
self.log.debug("[%s][%s] = %s" % (section, key, value))
self.debug("[%s][%s] = %s" % (section, key, value))
return value
except:
self.log.debug("[%s][%s] = None" % (section, key))
self.debug("[%s][%s] = None" % (section, key))
return None
 
def set(self, section, key, value):
55,7 → 55,7
with open(FILE['CNF'], 'r') as fp:
config = json.load(fp)
except Exception as error:
self.log.info("Config file not found. Creating a new one")
self.debug("Config file not found. Creating a new one")
config = {}
self.save(config)
 
68,54 → 68,4
return
with open(FILE['CNF'], 'w') as fp:
json.dump(config, fp)
self.log.debug("Settings saved successfully")
 
 
 
#~ class Settings(Service):
#~ ######
#~ # FIXME: right now, settings are hardcoded
#~ ######
#~ def initialize(self):
#~ view = self.get_config_value('View')
#~ self.log.debug("View: %s" % view)
 
#~ def get_default_settings(self):
#~ settings = {}
#~ utils = self.get_service('Utils')
#~ settings['CNF_SAP_LOGIN'] = LOGIN_PAGE_URL
#~ settings['CNF_SAP_LOGOUT'] = LOGOUT_PAGE_URL
#~ settings['CNF_SAP_ODATA_NOTES'] = ODATA_NOTE_URL
#~ settings['CNF_SAP_NOTE_URL'] = SAP_NOTE_URL
#~ settings['CNF_SAP_CONN_TIMEOUT'] = TIMEOUT
#~ settings['CNF_FF_PROFILE_DIR'] = utils.get_firefox_profile_dir()
 
#~ return settings
 
 
#~ def get_custom_settings(self):
#~ sap = self.get_service('SAP')
#~ utils = self.get_service('Utils')
 
#~ settings = {}
#~ settings['CNF_SAP_LOGIN'] = sap.get_config_value('CNF_SAP_LOGIN')
#~ settings['CNF_SAP_LOGOUT'] = sap.get_config_value('CNF_SAP_LOGOUT')
#~ settings['CNF_SAP_ODATA_NOTES'] = sap.get_config_value('CNF_SAP_ODATA_NOTES')
#~ settings['CNF_SAP_NOTE_URL'] = sap.get_config_value('CNF_SAP_NOTE_URL')
#~ settings['CNF_SAP_CONN_TIMEOUT'] = sap.get_config_value('CNF_SAP_CONN_TIMEOUT')
#~ settings['CNF_FF_PROFILE_DIR'] = sap.get_config_value('CNF_FF_PROFILE_DIR')
 
#~ return settings
 
 
#~ def get_value(self, key):
#~ settings = self.get_custom_settings()
 
#~ try:
#~ return settings[key]
#~ except:
#~ return None
 
 
#~ def set_value(self, key, value):
#~ pass
self.debug("Settings saved successfully")
/branches/BR-0.3/basico/stats.py
30,7 → 30,6
def build_pie_maincomp(self):
db = self.get_service('DB')
stats = db.get_stats()
#~ self.log.debug(stats)
CHART_FILE = self.app.get_var('TMP', 'local') + 'chart.svg'
config = Config()
config.show_legend = True
/branches/BR-0.3/basico/tasks.py
26,7 → 26,7
def __init_tasks_store(self):
TASKS_FILE = self.get_file('TASKS')
if not os.path.exists(TASKS_FILE):
self.log.info("Creating store for tasks: %s" % TASKS_FILE)
self.debug("Creating store for tasks: %s" % TASKS_FILE)
ftasks = open(TASKS_FILE, 'w')
ftasks.close()
 
144,7 → 144,7
self.uif.message_dialog(head , body)
else:
model.remove(iter)
self.log.info("Task deleted: %s" % task)
self.debug("Task deleted: %s" % task)
self.save_tasks()
 
 
156,12 → 156,12
found = False
for row in model:
if row[1].upper() == task.upper():
self.log.info("Task already exists: %s" % task)
self.debug("Task already exists: %s" % task)
found = True
 
if not found and len(task) > 0:
model.append([False, task])
self.log.info("Task added: %s" % task)
self.debug("Task added: %s" % task)
 
self.pname.set_text('')
self.save_tasks()
223,7 → 223,7
task = model.get_value(iter, 1)
if task in tasks:
model[path][0] = True
self.log.debug("Task '%s' switch to true" % task)
self.debug("Task '%s' switch to true" % task)
else:
model[path][0] = False
return False
265,7 → 265,6
ltasks = list(tasks)
ltasks.sort()
 
#~ self.log.debug("Tasks selected: %s" % ', '.join(tasks))
return ltasks
 
 
319,7 → 318,7
ftasks = open(TASKS_FILE, 'w')
for task in tasks:
ftasks.write("%s\n" % task)
self.log.info("Task saved: %s" % task)
self.debug("Task saved: %s" % task)
ftasks.close()
 
 
/branches/BR-0.3/basico/uiapp.py
20,7 → 20,6
 
from .service import Service
from .window import GtkAppWindow
from .log import get_logger
from .env import FILE, APP
 
class UIApp(Gtk.Application):
32,7 → 31,6
flags=Gio.ApplicationFlags.FLAGS_NONE)
GLib.set_application_name("Basico")
GLib.set_prgname('basico')
self.log = get_logger(self.__class__.__name__, FILE['LOG'])
self.controller = controller
self.get_services()
 
81,7 → 79,6
 
 
def cb_show_about(self, *args):
#~ self.cb.update_titlebar_title("About", "about")
DIR_ICONS = self.controller.get_var("ICONS")
CREDITS = self.controller.get_file("CREDITS")
rootwin = self.gui.get_widget('mainwindow')
/branches/BR-0.3/basico/uifuncs.py
26,10 → 26,10
 
def check_gtk_version(self):
vmajor, vminor, vmicro = self.get_gtk_version()
self.log.debug("GTK+ Version: %d.%d.%d" % (vmajor, vminor, vmicro))
self.debug("GTK+ Version: %d.%d.%d" % (vmajor, vminor, vmicro))
 
if vmajor == 3 and vminor >= 18:
self.log.debug("GTK+ version supported")
self.debug("GTK+ version supported")
return True
else:
self.log.error("Please, install a modern version of GTK+ (>= 3.18)")
81,8 → 81,6
item = Gio.MenuItem.new(name, action)
if len(icon) > 0:
item.set_icon(Gio.ThemedIcon.new(icon))
#~ item.set_always_show_image(True)
#~ icon = self.im.get_themed_icon(icon)
 
return item
 
102,29 → 100,3
dialog.format_secondary_text("%s" % body)
dialog.run()
dialog.destroy()
 
 
#~ def fullscreen(self, switch, active):
#~ window = self.gui.get_widget('mainwindow')
#~ btnwpunfull = self.gui.get_widget('btnWPUnfullscreen')
#~ if active:
#~ window.fullscreen()
#~ btnwpunfull.set_no_show_all(False)
#~ btnwpunfull.show_all()
#~ else:
#~ window.unfullscreen()
#~ btnwpunfull.set_no_show_all(True)
#~ btnwpunfull.hide()
 
 
def do_unfullscreen(self, *args):
# FIXME: use fullscreen method instead duplicate it
switch = self.gui.get_widget('fullscreen')
switch.set_active(False)
#~ self.fullscreen(switch, False)
 
#~ btnwpunfull = self.gui.get_widget('btnWPUnfullscreen')
#~ window = self.gui.get_widget('mainwindow')
#~ window.unfullscreen()
#~ btnwpunfull.set_no_show_all(True)
#~ btnwpunfull.hide()
/branches/BR-0.3/basico/utils.py
30,7 → 30,7
browser = webbrowser.get('windows-default')
 
for url in lurl:
self.log.debug("Browsing URL: %s" % url)
self.debug("Browsing URL: %s" % url)
browser.open_new_tab(url)
 
 
57,7 → 57,7
 
def install_geckodriver(self):
"""Get last version of Gecko webdriver from github"""
self.log.debug("OS Platform: %s" % sys.platform)
self.debug("OS Platform: %s" % sys.platform)
if sys.platform in ['linux', 'linux2']:
GECKO_SOURCE = "https://github.com/mozilla/geckodriver/releases/download/v0.19.1/geckodriver-v0.19.1-linux64.tar.gz"
GECKO_TARGET = self.get_var('TMP', scope='local') + 'gecko.tar.gz'
69,7 → 69,7
 
 
if os.path.exists(GECKO_TARGET):
self.log.debug("Gecko webdriver already downloaded")
self.debug("Gecko webdriver already downloaded")
downloaded = True
else:
downloaded = self.download('Gecko', GECKO_SOURCE, GECKO_TARGET)
80,7 → 80,7
elif sys.platform == 'win32':
extracted = self.extract(GECKO_TARGET, GECKO_INSTALL_DIR, 'zip')
if extracted:
self.log.debug("Gecko webdriver deployed successfully")
self.debug("Gecko webdriver deployed successfully")
else:
self.log.error("Gecko could not be deployed")
self.log.error("Tip: maybe %s is corrupt. Delete it" % GECKO_TARGET)
90,12 → 90,12
 
def download(self, prgname, source, target):
try:
self.log.debug ("Downloading %s from: %s" % (prgname, source))
self.debug ("Downloading %s from: %s" % (prgname, source))
response = requests.get(source, stream=True)
with open(target, 'wb') as out_file:
shutil.copyfileobj(response.raw, out_file)
del response
self.log.debug ("%s downloaded to %s" % (prgname, target))
self.debug ("%s downloaded to %s" % (prgname, target))
return True
except Exception as error:
self.log.error(error)
103,13 → 103,13
 
 
def extract(self, filename, target_path, protocol):
self.log.debug("Extracting %s to %s using protocol %s" % (filename, target_path, protocol))
self.debug("Extracting %s to %s using protocol %s" % (filename, target_path, protocol))
if protocol in ['tar.gz', 'bz2']:
try:
tar = tarfile.open(filename, "r:*")
tar.extractall(target_path)
tar.close()
self.log.debug("Extracted successfully")
self.debug("Extracted successfully")
return True
except Exception as error:
self.log.error(error)
117,7 → 117,7
elif protocol == 'zip':
try:
self.unzip(filename, target_path)
self.log.debug("Extracted successfully")
self.debug("Extracted successfully")
return True
except Exception as error:
self.log.error(error)
127,8 → 127,8
# http://stackoverflow.com/a/25650295
#~ make_archive(archive_name, 'gztar', root_dir)
res = shutil.make_archive(filename, 'gztar', directory)
self.log.debug("%s - %s" % (filename, directory))
self.log.debug("zip res: %s" % res)
self.debug("%s - %s" % (filename, directory))
self.debug("zip res: %s" % res)
 
 
def unzip(self, target, install_dir):
/branches/BR-0.3/basico/window.py
24,13 → 24,12
from gi.repository import WebKit
from gi.repository.GdkPixbuf import Pixbuf
 
from .log import get_logger
#~ from .sapnoteview import SAPNoteView
from .service import Service
 
 
MONOSPACE_FONT = 'Lucida Console' if platform.system() == 'Windows' else 'monospace'
 
class GtkAppWindow(Gtk.ApplicationWindow):
class GtkAppWindow(Gtk.ApplicationWindow, Service):
def __init__(self, uiapp):
self.setup_controller(uiapp)
self.get_services()
46,11 → 45,7
 
self.gui.get_service('Workplace')
 
# Then run webserver
#~ self.webserver = self.controller.get_service('WebServer')
#~ self.webserver.run()
 
 
def setup_controller(self, uiapp):
self.uiapp = uiapp
self.controller = uiapp.get_controller()
57,23 → 52,12
 
 
def setup_app(self):
#~ sapnoteview = self.gui.get_widget('viewmenu')
searchentry = self.gui.get_widget("stySearchInfo")
viewlabel = self.gui.get_widget('lblViewCurrent')
#~ try:
#~ name = sapnoteview.get_view()
#~ except:
#~ name = 'components'
#~ sapnoteview.set_view(name)
#~ label = "<span size='20000'><b>%-10s</b></span>" % name.capitalize()
#~ label = "<b>%-10s</b>" % name.capitalize()
#~ viewlabel.set_markup(label)
#~ self.cb.refresh_view()
searchentry.set_text('')
#~ self.cb.search_notes()
#~ sapnoteview.check_states()
 
 
 
def setup_window(self):
app_title = self.controller.get_app_info('name')
Gtk.Window.__init__(self, title=app_title, application=self.uiapp)
88,7 → 72,6
self.set_role(app_title)
self.set_default_size(1024, 728)
self.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
#~ self.connect('destroy', Gtk.main_quit)
 
# HEADERBAR WIDGETS
self.setup_headerbar()
127,8 → 110,6
lbltitlebar = self.gui.add_widget("lbltitlebar", Gtk.Label())
lbltitlebar.set_visible(False)
lbltitlebar.set_no_show_all(True)
#~ self.cb.update_titlebar_title("Dashboard", "dashboard")
#~ lbltitlebar.set_markup("<big><b>Dashboard</b></big>")
lhbox.pack_start(imgtitlebar, False, False, 3)
lhbox.pack_start(lbltitlebar, False, False, 3)
lhbox.show_all()
135,22 → 116,9
hb.pack_start(lhbox)
 
# Middle side titlebar
# Menu Actions
#~ def estoy_toggled(btnactions):
#~ total = self.db.get_total()
#~ self.log.debug("TOTAL: %d" % total)
#~ if total > 0:
#~ actions_menu = self.gui.get_widget('actions_menu')
#~ btnactions.set_menu_model(actions_menu)
#~ else:
#~ btnactions.set_menu_model(None)
 
#~ return True
 
label = self.gui.add_widget('lblSelectedNotes', Gtk.Label())
#~ label.set_markup('<b><small>0</small>/0 of <big>%d</big></b>' % self.db.get_total())
button = self.gui.add_widget('mnuBtnActions', Gtk.MenuButton())
#~ button.connect('toggled', estoy_toggled)
button.set_relief(Gtk.ReliefStyle.NONE)
button.set_no_show_all(False)
button.set_visible(False)
157,80 → 125,6
button.add(label)
mhbox.pack_start(button, False, False, 0)
 
# Quick SAP Note Entry
#~ label = Gtk.Label()
#~ label.set_markup("<b>Quick SAP Note </b>")
#~ mhbox.pack_start(label, False, False, 0)
#~ entry = Gtk.Entry()
#~ entry.set_max_length(10)
#~ entry.set_max_width_chars(5)
#~ entry.set_width_chars(10)
#~ entry.set_alignment(xalign=1)
#~ mhbox.pack_start(entry, False, False, 0)
 
# Dashboard button
#~ button = self.gui.add_widget('btnDashboard', Gtk.Button())
#~ button.set_tooltip_markup('<big><b>Dashboard</b></big>')
#~ icon = self.im.get_pixbuf_icon('dashboard', 24, 24)
#~ image = Gtk.Image()
#~ image.set_from_pixbuf(icon)
#~ button.set_image(image)
#~ button.set_relief(Gtk.ReliefStyle.NONE)
#~ button.connect('clicked', self.cb.show_dashboard)
#~ mhbox.pack_start(button, False, False, 0)
 
# Workplace button
#~ button = Gtk.Button()
#~ button.set_tooltip_markup('<big><b>Workplace</b></big>')
#~ icon = self.im.get_pixbuf_icon('workplace', 24, 24)
#~ image = Gtk.Image()
#~ image.set_from_pixbuf(icon)
#~ button.set_image(image)
#~ button.set_relief(Gtk.ReliefStyle.NONE)
#~ button.connect('clicked', self.cb.show_workplace)
#~ mhbox.pack_start(button, False, False, 0)
 
 
# Workbook button
#~ button = Gtk.Button()
#~ button.set_tooltip_markup('<big><b>Workbook</b></big>')
#~ icon = self.im.get_pixbuf_icon('comments', 24, 24)
#~ image = Gtk.Image()
#~ image.set_from_pixbuf(icon)
#~ button.set_image(image)
#~ button.set_relief(Gtk.ReliefStyle.NONE)
#~ button.connect('clicked', self.cb.show_workbook)
#~ mhbox.pack_start(button, False, False, 0)
 
 
# School button
#~ button = Gtk.Button()
#~ button.set_tooltip_markup('<big><b>My SAP School</b></big>')
#~ icon = self.im.get_pixbuf_icon('school', 24, 24)
#~ image = Gtk.Image()
#~ image.set_from_pixbuf(icon)
#~ button.set_image(image)
#~ button.set_relief(Gtk.ReliefStyle.NONE)
#~ button.connect('clicked', self.cb.show_school)
#~ mhbox.pack_start(button, False, False, 0)
 
#~ label = Gtk.Label()
#~ label.set_markup("<b> SAP Note </b>")
#~ mhbox.pack_start(label, False, False, 0)
 
 
# Search entry
#~ button = Gtk.Button()
#~ button.set_tooltip_markup('<big><b>Search</b></big>')
#~ icon = self.im.get_pixbuf_icon('bsearch', 24, 24)
#~ image = Gtk.Image()
#~ image.set_from_pixbuf(icon)
#~ button.set_image(image)
#~ button.set_relief(Gtk.ReliefStyle.NONE)
#~ button.connect('clicked', self.cb.toggle_search)
#~ mhbox.pack_start(button, False, False, 0)
 
 
# Right side titlebar
# MnuButton valid with any modern version of Gtk (?> 3.10)
btnactions = self.gui.add_widget('mnuBtnImport', Gtk.MenuButton())
302,27 → 196,8
button.set_relief(Gtk.ReliefStyle.NONE)
button.connect('clicked', self.cb.show_settings)
box.pack_start(button, False, False, 0)
 
popover.add(box)
 
#~ # Settings
#~ button = Gtk.Button()
#~ button.set_tooltip_markup('<big><b>Settings</b></big>')
#~ icon = self.im.get_pixbuf_icon('settings', 24, 24)
#~ image = Gtk.Image()
#~ image.set_from_pixbuf(icon)
#~ button.set_image(image)
#~ button.set_relief(Gtk.ReliefStyle.NONE)
 
# Popover settings
#~ popover = self.setup_popover_settings(button)
#~ button.connect('clicked', self.cb.show_settings, popover)
#~ button.show_all()
#~ self.cb.update_titlebar_title("Settings", "settings")
#~ rhbox.pack_end(button, False, False, 0)
 
hb.pack_end(rhbox)
 
hb.set_custom_title(mhbox)
self.set_titlebar(hb)
hb.show_all()
331,7 → 206,6
def setup_dashboard_filters(self):
### SETTINGS POPOVER
menu = Gio.Menu()
#~ self.gui.add_widget("menu", menu)
menu.append_item(self.uif.create_item('Fullscreen', 'app.settings-fullscreen', 'gtk-fullscreen'))
menu.append_item(self.uif.create_item('Rename current project', 'app.project-rename', 'preferences-desktop-personal'))
menu.append_item(self.uif.create_item('Refresh current project', 'app.project-refresh', 'view-refresh'))
343,7 → 217,6
app = self.gui.get_app()
app.add_action(self.uif.create_item("settings-fullscreen"))
 
#~ popover_action_group = Gio.SimpleActionGroup()
button = self.gui.get_widget('btnDashboard')
popover_dashboard = Gtk.Popover.new_from_model(button, menu)
popover_dashboard.set_position(Gtk.PositionType.BOTTOM)
350,26 → 223,6
button.connect('clicked', lambda _: popover_dashboard.show_all())
 
 
#~ def setup_menu_settings(self):
#~ ### SETTINGS POPOVER
#~ menu = Gio.Menu()
#~ menu.append_item(self.uif.create_item('Fullscreen', 'app.settings-fullscreen', 'gtk-fullscreen'))
#~ menu.append_item(self.uif.create_item('Rename current project', 'app.project-rename', 'preferences-desktop-personal'))
#~ menu.append_item(self.uif.create_item('Refresh current project', 'app.project-refresh', 'view-refresh'))
#~ menu.append_item(self.uif.create_item('Close current project', 'app.project-close', 'window-close'))
#~ menu.append_item(self.uif.create_item('Delete current project', 'app.project-delete', 'list-remove'))
#~ menu.append_item(self.uif.create_item('Export current project', 'app.project-delete', 'document-save-as'))
#~ window = self.gui.get_window()
#~ window.set_app_menu(menu)
#~ app = self.gui.get_app()
#~ app.add_action(self.uif.create_item("settings-fullscreen"))
 
#~ btnsettings = self.gui.get_widget("mnuBtnViews")
#~ popover_settings = Gtk.Popover.new_from_model(btnsettings, menu)
#~ popover_settings.set_position(Gtk.PositionType.BOTTOM)
#~ btnsettings.connect('clicked', lambda _: popover_settings.show_all())
 
 
def setup_popover_settings(self, widget):
#Creating a popover
popover = Gtk.Popover.new(widget)
391,10 → 244,6
 
def setup_menus(self):
pass
#~ self.setup_menu_views()
#~ self.setup_dashboard_filters
#~ self.cb.setup_menu_actions()
#~ self.setup_menu_settings()
 
 
def show_home_page(self, *args):
455,13 → 304,6
self.mainbox = self.gui.get_widget('mainbox')
self.mainbox.reparent(self)
 
#~ # STATUSBAR WIDGETS
# StatusBar disabled
#~ statusbar = self.gui.get_widget('pgbMain')
#~ statusbar.set_text("")
#~ statusbar.set_show_text(True)
#~ statusbar.set_fraction(0.0)
 
# SETUP MENUS
self.setup_menus()
 
479,138 → 321,12
button.connect('clicked', self.cb.default_preferences)
 
# SAPNOTEVIEW WIDGETS
#~ viewsbox = self.gui.get_widget('viewsbox')
#~ notesbox = self.gui.get_widget('notesbox')
#~ viewmenu = SAPNoteView(self.controller)
#~ viewnotes = SAPNoteView(self.controller)
#~ self.gui.add_widget('viewmenu', viewmenu)
self.gui.add_widget('combobox')
search = self.gui.add_widget('stySearchInfo')
#~ search.connect('search_changed', self.search_notes)
search.connect('activate', self.cb.search_notes)
self.setup_combobox_search()
#~ self.swap_widget(viewsbox, viewmenu)
 
 
#~ self.setup_props_window()
 
 
# Buttons
# Task link button
#~ self.cb.check_task_link_button_status()
 
#~ # button quit
#~ image = self.gui.get_widget('imgBtnQuit')
#~ icon = self.im.get_pixbuf_icon('power', 48, 48)
#~ image.set_from_pixbuf(icon)
#~ button = self.gui.get_widget('btnQuit')
#~ button.connect('clicked', self.gui.quit)
 
#~ # button about
#~ image = self.gui.get_widget('imgBtnAbout')
#~ icon = self.im.get_pixbuf_icon('about', 48, 48)
#~ image.set_from_pixbuf(icon)
#~ button = self.gui.get_widget('btnAbout')
#~ button.connect('clicked', self.uiapp.cb_show_about)
 
#~ # button settings
#~ image = self.gui.get_widget('imgBtnSettings')
#~ icon = self.im.get_pixbuf_icon('settings', 48, 48)
#~ image.set_from_pixbuf(icon)
#~ button = self.gui.get_widget('btnSettings')
#~ button.connect('clicked', self.show_settings_page)
 
#~ # button stats
#~ image = self.gui.get_widget('imgBtnStats')
#~ icon = self.im.get_pixbuf_icon('chart', 48, 48)
#~ image.set_from_pixbuf(icon)
#~ button = self.gui.get_widget('btnShowStats')
#~ button.connect('clicked', self.show_stats_page)
 
#~ # button show property details
#~ image = self.gui.get_widget('imgBtnShowProps')
#~ icon = self.im.get_pixbuf_icon('fingerprint', 48, 48)
#~ image.set_from_pixbuf(icon)
#~ button = self.gui.get_widget('btnShowProperties')
#~ button.connect('clicked', self.cb.show_properties)
 
#~ # button show manage window
#~ image = self.gui.get_widget('imgBtnShowManage')
#~ icon = self.im.get_pixbuf_icon('subwindow', 48, 48)
#~ image.set_from_pixbuf(icon)
#~ button = self.gui.get_widget('tgbShowManage')
#~ button.connect('toggled', self.switch_props_window)
 
#~ # button search
#~ image = self.gui.get_widget('imgBtnSearch')
#~ icon = self.im.get_pixbuf_icon('bsearch', 48, 48)
#~ image.set_from_pixbuf(icon)
#~ button = self.gui.get_widget('tgbSearch')
#~ button.connect('toggled', self.cb.show_search)
#~ revsearch = self.gui.get_widget('revSearch')
#~ revsearch.hide()
#~ revsearch.set_no_show_all(True)
 
# button import
#~ image = self.gui.get_widget('imgMnuBtnImport')
#~ icon = self.im.get_pixbuf_icon('import', 24, 24)
#~ image.set_from_pixbuf(icon)
 
#~ # button refresh
#~ image = self.gui.get_widget('imgBtnRefresh')
#~ icon = self.im.get_pixbuf_icon('refresh', 48, 48)
#~ image.set_from_pixbuf(icon)
#~ button = self.gui.get_widget('btnRefreshSAPNoteView')
#~ button.connect('clicked', self.cb.refresh_and_clear_view)
 
#~ button = self.gui.get_widget('btnLinkTasksApply')
#~ button.connect('clicked', self.cb.link_tasks_to_sapnotes)
 
#~ btnaddnote = self.gui.get_widget('btnStartDlNotes')
#~ btnaddnote.connect('clicked', self.cb.import_notes)
 
#~ btnStopDlNotes = self.gui.get_widget('btnStopDlNotes')
#~ btnStopDlNotes.connect('clicked', self.cb.stop_dl_notes)
 
#~ switch = self.gui.get_widget('schExpandCollapse')
#~ switch.connect('state-set', viewmenu.expand_collapse)
#~ switch.connect('toggled', sapnoteview.expand_collapse)
#~ switch = self.gui.get_widget('schSelectNotesAllNone')
#~ switch.connect('state-set', viewmenu.select_all_none)
#~ switch.connect('toggled', viewmenu.select_all_none)
 
 
#~ # Actions button
#~ button = self.gui.get_widget('mnuBtnActions')
 
#~ sap_settings = self.prefs.get_custom_settings()
#~ for setting in sap_settings:
#~ try:
#~ widget = self.gui.add_widget(setting)
#~ widget.set_text(sap_settings[setting])
#~ except:
#~ pass
 
 
#~ # Stats
#~ statsviewer = self.gui.add_widget('scrStatsViewer')
 
#~ btnstats = self.gui.add_widget('btnStatsByCompMain')
#~ btnstats.connect('clicked', self.cb.update_components_stats)
#~ iconwdg = self.gui.add_widget('imgStatsByCompMain')
#~ icon = self.im.get_pixbuf_icon('component', 64, 64)
#~ iconwdg.set_from_pixbuf(icon)
 
#~ btnstats = self.gui.add_widget('btnStatsByCategory')
#~ btnstats.connect('clicked', self.cb.update_categories_stats)
#~ iconwdg = self.gui.add_widget('imgStatsByCategory')
#~ icon = self.im.get_pixbuf_icon('category', 64, 64)
#~ iconwdg.set_from_pixbuf(icon)
 
#~ self.hide_props_window()
self.show_all()
self.log.debug("GUI loaded")
 
#~ self.debug("GUI loaded")
self.cb.show_workplace()
 
 
622,14 → 338,6
trvprops = self.gui.add_widget('trvprops', Gtk.TreeView())
trvprops.set_model(model)
 
#~ ## key
#~ renderer = Gtk.CellRendererText()
#~ column = Gtk.TreeViewColumn('Id', renderer, text=0)
#~ column.set_visible(False)
#~ column.set_clickable(False)
#~ column.set_sort_indicator(False)
#~ trvprops.append_column(column)
 
# Property
renderer = Gtk.CellRendererText()
renderer.set_alignment(1.0, 0.5)
664,11 → 372,10
self.gui.swap_widget(container, trvprops)
 
def set_notes_manager_pane_position(self, pane, rectangle):
pass
#~ self.log.debug(type(pane.get_allocation()))
#~ self.controller.debug(type(pane.get_allocation()))
position = rectangle.width/5*3
pane.set_position(position)
self.log.debug("Pane position: %s" % position)
self.debug("Pane position: %s" % position)
 
 
def __completion_func(self, completion, key, iter):
745,8 → 452,6
"""
self.gui = self.controller.get_service("GUI")
self.app = self.gui.get_app()
LOG_FILE = self.controller.get_file('LOG')
self.log = get_logger('GtkAppWindow', LOG_FILE)
self.db = self.controller.get_service("DB")
self.uif = self.controller.get_service("UIF")
self.prefs = self.controller.get_service("Settings")
753,8 → 458,6
self.im = self.controller.get_service('IM')
self.cb = self.controller.get_service('Callbacks')
self.tasks = self.controller.get_service('Tasks')
#~ self.visor = self.controller.get_service('Workplace')
#~ self.dashboard = self.controller.get_service('Dashboard')
 
 
def swap_widget(self, container, combobox):
/branches/BR-0.3/setup.py
157,9 → 157,6
'Topic :: Utilities'
],
entry_points={
#~ 'console_scripts': [
#~ 'basico = basico:main',
#~ ],
'gui_scripts': [
'basico = basico.basico:main',
]