[POS-commit] r1170 - in fiscalprinter/trunk/fiscalprinter: .
drivers gui gui/glade
Adriano Monteiro Marques
pyone at async.com.br
Fri Sep 9 12:45:09 BRT 2005
Author: pyone
Date: Fri Sep 9 12:45:08 2005
New Revision: 1170
Modified:
fiscalprinter/trunk/fiscalprinter/drivers/basedriver.py
fiscalprinter/trunk/fiscalprinter/gui/glade/main.glade
fiscalprinter/trunk/fiscalprinter/gui/main.py
fiscalprinter/trunk/fiscalprinter/log.py
Log:
log.py bug fixed. main.glade improvements and basedriver.py using Log class
Modified: fiscalprinter/trunk/fiscalprinter/drivers/basedriver.py
==============================================================================
--- fiscalprinter/trunk/fiscalprinter/drivers/basedriver.py (original)
+++ fiscalprinter/trunk/fiscalprinter/drivers/basedriver.py Fri Sep 9 12:45:08 2005
@@ -35,6 +35,7 @@
from fiscalprinter.exceptions import CriticalError
from fiscalprinter.configparser import FiscalPrinterConfig
+from fiscalprinter.log import Log
class BaseDriver:
@@ -75,24 +76,24 @@
self.log('Config passed to __init__: \n' + config_str)
self._init_device(self.config)
+
def _init_log(self):
- self.fp_debug = None
if not os.environ.has_key('FISCALPRINTER_DEBUG'):
+ # Setting warning level, and standard output for messages
+ self.logger = Log(sys.stdout, 40)
return
+
if os.environ['FISCALPRINTER_DEBUG'] == 'STDOUT':
- self.fp_debug = sys.stdout
+ self.logger = Log(sys.stdout)
elif os.environ['FISCALPRINTER_DEBUG'] == 'STDERR':
- self.fp_debug = sys.stderr
+ self.logger = Log(sys.stderr)
else:
- try:
- self.fp_debug = open(os.environ['FISCALPRINTER_DEBUG'],
- 'a', buffering=1)
- except IOError:
- sys.stderr.write('\n\nWARNING, log file could not be '
- 'opened. Debug Logging is disabled.\n\n')
- self.fp_debug = None
-
+ self.logger = Log(open(os.environ['FISCALPRINTER_DEBUG'],
+ 'a', buffering=1))
+
+ self.log = self.logger.log
+
def _init_device(self, config):
# Default is SerialDevice (pySerial)
if config.get_devicetype() == 'serial':
@@ -110,9 +111,3 @@
"'config' parameter and supply a "
"'device-type' of either 'serial', "
"'posixserial' or 'network'")
-
- def log(self, message):
- if self.fp_debug is not None:
- timestamp = time.strftime("%d/%m/%Y %H:%M:%S", time.localtime())
- message_logged = "%s - %s\n" % (timestamp, message)
- self.fp_debug.write(str(message_logged))
Modified: fiscalprinter/trunk/fiscalprinter/gui/glade/main.glade
==============================================================================
--- fiscalprinter/trunk/fiscalprinter/gui/glade/main.glade (original)
+++ fiscalprinter/trunk/fiscalprinter/gui/glade/main.glade Fri Sep 9 12:45:08 2005
@@ -91,6 +91,12 @@
</object>
</child>
<child>
+ <object class="GtkAction" id="setup_printer">
+ <property name="name">setup_printer</property>
+ <property name="label" translatable="yes">Setup Printer</property>
+ </object>
+ </child>
+ <child>
<object class="GtkAction" id="summarize">
<property name="name">summarize</property>
<property name="label" translatable="yes">Summarize</property>
@@ -109,26 +115,86 @@
<child>
<object class="GtkActionGroup" id="Coupon">
<child>
+ <object class="GtkAction" id="add_item">
+ <property name="name">add_item</property>
+ <property name="label" translatable="yes">Add Item</property>
+ <property name="stock_id">gtk-add</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkAction" id="cancel_item">
+ <property name="name">cancel_item</property>
+ <property name="label" translatable="yes">Cancel Item</property>
+ <property name="stock_id">gtk-cancel</property>
+ </object>
+ </child>
+ <child>
<object class="GtkAction" id="cancel_last_coupon">
<property name="name">cancel_last_coupon</property>
- <property name="label" translatable="yes">Cancel last coupon</property>
+ <property name="label" translatable="yes">Cancel Coupon</property>
<property name="stock_id">gtk-cancel</property>
</object>
</child>
<child>
+ <object class="GtkAction" id="close_coupon">
+ <property name="name">close_coupon</property>
+ <property name="label" translatable="yes">Close Coupon</property>
+ <property name="stock_id">gtk-print</property>
+ </object>
+ </child>
+ <child>
<object class="GtkAction" id="coupon">
<property name="name">coupon</property>
<property name="label" translatable="yes">Coupon</property>
</object>
</child>
+ <child>
+ <object class="GtkAction" id="discount_charge_coupon">
+ <property name="name">discount_charge_coupon</property>
+ <property name="label" translatable="yes">Discount/Charge Coupon</property>
+ <property name="stock_id">gtk-remove</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkAction" id="open_coupon">
+ <property name="name">open_coupon</property>
+ <property name="label" translatable="yes">Open Coupon</property>
+ <property name="stock_id">gtk-open</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkAction" id="totalize_coupon">
+ <property name="name">totalize_coupon</property>
+ <property name="label" translatable="yes">Totalize Coupon</property>
+ <property name="stock_id">gtk-print-preview</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkActionGroup" id="Printer">
+ <child>
+ <object class="GtkAction" id="setup_printer">
+ <property name="name">setup_printer</property>
+ <property name="label" translatable="yes">Setup Printer</property>
+ </object>
+ </child>
</object>
</child>
<ui id="initial-state"><![CDATA[<ui><menubar action="menubar1" name="menubar1">
-<menu action="printer" name="printer"><menuitem action="connect_printer" name="connect_printer"/><separator/><menuitem action="summarize" name="summarize"/><menuitem action="summarize_close" name="summarize_close"/><separator/><menuitem action="Quit" name="Quit"/></menu><menu action="coupon" name="coupon"><menuitem action="cancel_last_coupon" name="cancel_last_coupon"/></menu></menubar></ui>]]></ui>
+<menu action="printer" name="printer"><menuitem action="setup_printer" name="setup_printer"/><menuitem action="connect_printer" name="connect_printer"/><separator/><menuitem action="summarize" name="summarize"/><menuitem action="summarize_close" name="summarize_close"/><separator/><menuitem action="Quit" name="Quit"/></menu><menu action="coupon" name="coupon"><menuitem action="open_coupon" name="open_coupon"/><separator/><menuitem action="add_item" name="add_item"/><menuitem action="cancel_item" name="cancel_item"/><separator/><menuitem action="discount_charge_coupon" name="discount_charge_coupon"/><menuitem action="close_coupon" name="close_coupon"/><menuitem action="totalize_coupon" name="totalize_coupon"/><separator/><menuitem action="cancel_last_coupon" name="cancel_last_coupon"/></menu></menubar><toolbar action="toolbar1" name="toolbar1">
+
+
+
+
+
+
+
+<toolitem action="open_coupon" name="open_coupon"/><separator/><toolitem action="add_item" name="add_item"/><toolitem action="cancel_item" name="cancel_item"/><separator/><toolitem action="discount_charge_coupon" name="discount_charge_coupon"/><toolitem action="close_coupon" name="close_coupon"/><toolitem action="totalize_coupon" name="totalize_coupon"/><separator/><toolitem action="cancel_last_coupon" name="cancel_last_coupon"/></toolbar></ui>]]></ui>
</object>
- <widget class="GtkWindow" id="MainWindow">
+ <widget class="GtkWindow" id="main">
<property name="default_height">250</property>
<property name="default_width">440</property>
<property name="title" context="yes" translatable="yes">FiscalPrinter </property>
@@ -145,6 +211,16 @@
</packing>
</child>
<child>
+ <widget constructor="initial-state" class="GtkToolbar" id="toolbar1">
+ <property name="visible">True</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
<widget class="GtkNotebook" id="notebook1">
<property name="is_focus">True</property>
<property name="visible">True</property>
@@ -173,7 +249,7 @@
</child>
</widget>
<packing>
- <property name="position">1</property>
+ <property name="position">2</property>
</packing>
</child>
<child>
@@ -183,7 +259,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">2</property>
+ <property name="position">3</property>
</packing>
</child>
</widget>
Modified: fiscalprinter/trunk/fiscalprinter/gui/main.py
==============================================================================
--- fiscalprinter/trunk/fiscalprinter/gui/main.py (original)
+++ fiscalprinter/trunk/fiscalprinter/gui/main.py Fri Sep 9 12:45:08 2005
@@ -31,16 +31,25 @@
import gettext
import gtk
+import os
_ = gettext.gettext
-
-from kiwi.environ import require_gazpacho
+from kiwi.environ import require_gazpacho, environ
require_gazpacho()
from kiwi.datatypes import ValidationError
from kiwi.ui.delegates import Delegate
+#XXX
+this_dir = os.path.dirname(__file__)
+if os.path.exists(os.path.join(this_dir, "..", "..", "setup.py")):
+ environ.add_resource("glade", os.path.join(this_dir, "glade"))
+else:
+ environ.add_resource("glade", SYSTEM_GLADEPATH)
+
+import fiscalprinter
+
class MainWindow(Delegate):
def __init__(self):
Delegate.__init__(self, gladefile='main',
Modified: fiscalprinter/trunk/fiscalprinter/log.py
==============================================================================
--- fiscalprinter/trunk/fiscalprinter/log.py (original)
+++ fiscalprinter/trunk/fiscalprinter/log.py Fri Sep 9 12:45:08 2005
@@ -88,7 +88,7 @@
# in a log message like this:
# 2005-09-07 18:15:12,636 (WARNING) - (message!)
format_string = ("%(asctime)s (%(levelname)s) - %(message)s")
- stream_handler.setFormatter(logging.Formatter, format_string)
+ stream_handler.setFormatter(logging.Formatter(format_string))
self.addHandler(stream_handler)
def log(self, message, level=log_level):
More information about the POS-commit
mailing list