billreminder r644 - in trunk: . src/daemon src/lib
- From: ogmaciel svn gnome org
- To: svn-commits-list gnome org
- Subject: billreminder r644 - in trunk: . src/daemon src/lib
- Date: Wed, 24 Sep 2008 12:50:31 +0000 (UTC)
Author: ogmaciel
Date: Wed Sep 24 12:50:31 2008
New Revision: 644
URL: http://svn.gnome.org/viewvc/billreminder?rev=644&view=rev
Log:
Dbus work done by Luiz Armesto.
Modified:
trunk/ChangeLog
trunk/src/daemon/alarm.py
trunk/src/daemon/dbus_manager.py
trunk/src/lib/actions.py
trunk/src/lib/dbus_actions.py
Modified: trunk/src/daemon/alarm.py
==============================================================================
--- trunk/src/daemon/alarm.py (original)
+++ trunk/src/daemon/alarm.py Wed Sep 24 12:50:31 2008
@@ -35,7 +35,6 @@
def start(self):
start_delay = self.gconf_client.get_int(GCONF_PATH + 'delay') * 60000
- print start_delay
if self.gconf_client.get_bool(GCONF_ALARM_PATH + 'show_startup_notification'):
timeout_add(start_delay, self.show_pay_notification)
timeout_add(start_delay + 12000, self.verify_due)
Modified: trunk/src/daemon/dbus_manager.py
==============================================================================
--- trunk/src/daemon/dbus_manager.py (original)
+++ trunk/src/daemon/dbus_manager.py Wed Sep 24 12:50:31 2008
@@ -5,7 +5,7 @@
import dbus
import dbus.service
-from lib import common
+from lib import common, scheduler
from lib.utils import force_string
from lib.utils import get_dbus_interface as get_interface
from lib.utils import verify_dbus_service as verify_service
@@ -55,26 +55,39 @@
self.parent.client_pid = pid
return self.parent.client_pid
+ @dbus.service.method(common.DBUS_INTERFACE, in_signature='iii', out_signature='a(sis)')
+ def get_monthly_totals(self, status, month, year):
+ # Return a list of categories and totals for the given month
+ ret = []
+ records = self.actions.get_monthly_totals(status, month, year)
+ for record in records:
+ ret.append(record)
+ return ret
+
+ @dbus.service.method(common.DBUS_INTERFACE, in_signature='iii', out_signature='aa{ss}')
+ def get_monthly_bills(self, status, month, year):
+ ret = []
+ records = self.actions.get_monthly_bills(status, month, year)
+ for record in records:
+ ret.append(force_string(record))
+ return ret
+
@dbus.service.method(common.DBUS_INTERFACE, in_signature='a{ss}', out_signature='aa{ss}')
def get_bills(self, kwargs):
""" Returns one or more records that meet the criteria passed """
- print kwargs
ret = []
records = self.actions.get_bills(kwargs)
for record in records:
ret.append(force_string(record))
- print ret
return ret
@dbus.service.method(common.DBUS_INTERFACE, in_signature='s', out_signature='aa{ss}')
def get_bills_(self, kwargs):
""" Returns one or more records that meet the criteria passed """
- #print kwargs
ret = []
records = self.actions.get_bills(kwargs)
for record in records:
ret.append(force_string(record))
- print ret
return ret
@dbus.service.method(common.DBUS_INTERFACE, in_signature='a{ss}', out_signature='a{ss}')
@@ -104,23 +117,19 @@
@dbus.service.method(common.DBUS_INTERFACE, in_signature='a{ss}', out_signature='aa{ss}')
def get_categories(self, kwargs):
""" Returns one or more records that meet the criteria passed """
- print kwargs
ret = []
records = self.actions.get_categories(kwargs)
for record in records:
ret.append(force_string(record))
- print ret
return ret
@dbus.service.method(common.DBUS_INTERFACE, in_signature='s', out_signature='aa{ss}')
def get_categories_(self, kwargs):
""" Returns one or more records that meet the criteria passed """
- #print kwargs
ret = []
records = self.actions.get_categories(kwargs)
for record in records:
ret.append(force_string(record))
- print ret
return ret
@dbus.service.method(common.DBUS_INTERFACE, in_signature='a{ss}', out_signature='a{ss}')
Modified: trunk/src/lib/actions.py
==============================================================================
--- trunk/src/lib/actions.py (original)
+++ trunk/src/lib/actions.py Wed Sep 24 12:50:31 2008
@@ -94,9 +94,9 @@
self.edit_bill(bill)
return self.dal.delete(CategoriesTable, key)
-"""
+
if not '--standalone' in sys.argv \
and not sys.argv[0].endswith('billreminderd') \
and verify_dbus_service(common.DBUS_INTERFACE):
from lib.dbus_actions import Actions
-"""
+
Modified: trunk/src/lib/dbus_actions.py
==============================================================================
--- trunk/src/lib/dbus_actions.py (original)
+++ trunk/src/lib/dbus_actions.py Wed Sep 24 12:50:31 2008
@@ -33,6 +33,9 @@
return False
def _correct_type(self, record):
+ if not isinstance(record, dict):
+ return record
+
if 'Id' in record.keys():
record['Id'] = int(record['Id'])
if 'dueDate' in record.keys():
@@ -43,44 +46,36 @@
record['paid'] = int(record['paid'])
if 'alarm' in record.keys():
record['alarm'] = int(record['alarm'])
- if 'caId' in record.keys():
- record['caId'] = int(record['caId'])
+ if 'catId' in record.keys():
+ record['catId'] = int(record['catId'])
return record
def get_monthly_totals(self, status, month, year):
# Return a list of categories and totals for the given month
- # Delimeters for our search
- firstOfMonth = scheduler.first_of_month(month, year)
- lastOfMonth = scheduler.last_of_month(month, year)
-
- # Determine status criteria
- status = status < 2 and ' = %s' % status or ' in (0,1)'
-
- stmt = 'select categoryName, sum(amountDue) as amount, color' \
- ' from br_billstable, br_categoriestable where' \
- ' paid %s' \
- ' and dueDate >= ? and dueDate <= ?' \
- ' and br_categoriestable.Id = br_billstable.catId' \
- ' GROUP BY catId, color' \
- ' ORDER BY dueDate ASC' % status
- params = [firstOfMonth, lastOfMonth]
- records = self.executeSql(stmt, params)
+ #try:
+ ret = []
+ records = self.dbus_interface.get_monthly_totals(status, month, year)
+ for record in records:
+ record = self._correct_type(record)
+ ret.append(record)
+ return ret
+ #except dbus.DBusException:
+ # if self.__init__():
+ # return self.get_monthly_totals(status, month, year)
- return records
def get_monthly_bills(self, status, month, year):
- # Delimeters for our search
- firstOfMonth = scheduler.first_of_month(month, year)
- lastOfMonth = scheduler.last_of_month(month, year)
-
- # Determine status criteria
- status = status < 2 and ' = %s' % status or ' in (0,1)'
-
- records = self.get_bills('paid %s' \
- ' and dueDate >= %s and dueDate <= %s' \
- ' ORDER BY dueDate DESC' % (status, firstOfMonth, lastOfMonth))
- return records
-
+ try:
+ ret = []
+ records = self.dbus_interface.get_monthly_bills(status, month, year)
+ for record in records:
+ record = self._correct_type(record)
+ ret.append(record)
+ return ret
+ except dbus.DBusException:
+ if self.__init__():
+ return self.get_monthly_bills(status, month, year)
+
def get_bills(self, kwargs):
""" Returns one or more records that meet the criteria passed """
try:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]