--- bitpim-1.0.2.dfsg.1.orig/src/csv_calendar.py +++ bitpim-1.0.2.dfsg.1/src/csv_calendar.py @@ -10,7 +10,6 @@ "Deals with CSV calendar import/export stuff" # System modules -from __future__ import with_statement import csv import datetime @@ -23,7 +22,6 @@ import bpcalendar import common_calendar import helpids -import guihelper module_debug=False @@ -77,8 +75,10 @@ except: f=None if f is None: - guihelper.MessageDialog(self, 'Failed to open file ['+filename+']', - 'Export Error') + dlg=wx.MessageDialog(self, 'Failed to open file ['+filename+']', + 'Export Error') + dlg.ShowModal() + dlg.Destroy() return s=['"'+x[0]+'"' for x in csv_event_template]+\ ['"'+x[0]+'"' for x in csv_repeat_template] @@ -456,27 +456,31 @@ wx.EVT_BUTTON(self, self.ID_MERGE, self.OnEndModal) wx.EVT_BUTTON(self, wx.ID_HELP, lambda *_: wx.GetApp().displayhelpid(helpids.ID_DLG_CALENDAR_IMPORT)) - @guihelper.BusyWrapper def OnImport(self, evt): - with guihelper.WXDialogWrapper(wx.ProgressDialog('CSV Calendar Import', - 'Importing CSV Calendar Data, please wait ...', - parent=self)) as dlg: - self.__oc.read(self.folderctrl.GetValue()) - self.populate(self.__oc.get_display_data()) + wx.BeginBusyCursor() + dlg=wx.ProgressDialog('CSV Calendar Import', + 'Importing CSV Calendar Data, please wait ...', + parent=self) + self.__oc.read(self.folderctrl.GetValue()) + self.populate(self.__oc.get_display_data()) + dlg.Destroy() + wx.EndBusyCursor() def OnBrowseFolder(self, evt): - with guihelper.WXDialogWrapper(wx.FileDialog(self, "Pick a CSV Calendar File", wildcard='*.csv'), - True) as (dlg, id): - if id==wx.ID_OK: - self.folderctrl.SetValue(dlg.GetPath()) + dlg=wx.FileDialog(self, "Pick a CSV Calendar File", wildcard='*.csv') + id=dlg.ShowModal() + if id==wx.ID_CANCEL: + dlg.Destroy() + return + self.folderctrl.SetValue(dlg.GetPath()) + dlg.Destroy() def OnFilter(self, evt): cat_list=self.__oc.get_category_list() - with guihelper.WXDialogWrapper(common_calendar.FilterDialog(self, -1, 'Filtering Parameters', cat_list), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - self.__oc.set_filter(dlg.get()) - self.populate(self.__oc.get_display_data()) + dlg=common_calendar.FilterDialog(self, -1, 'Filtering Parameters', cat_list) + if dlg.ShowModal()==wx.ID_OK: + self.__oc.set_filter(dlg.get()) + self.populate(self.__oc.get_display_data()) def OnEndModal(self, evt): self.EndModal(evt.GetId()) @@ -532,11 +536,14 @@ main_bs.Fit(self) def OnBrowseFolder(self, evt): - with guihelper.WXDialogWrapper(wx.FileDialog(self, "Pick a CSV Calendar File", wildcard='*.csv'), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - self.folderctrl.SetValue(dlg.GetPath()) - self.__read=False + dlg=wx.FileDialog(self, "Pick a CSV Calendar File", wildcard='*.csv') + id=dlg.ShowModal() + if id==wx.ID_CANCEL: + dlg.Destroy() + return + self.folderctrl.SetValue(dlg.GetPath()) + self.__read=False + dlg.Destroy() def OnFilter(self, evt): # read the calender to get the category list @@ -544,10 +551,10 @@ self._oc.read(self.folderctrl.GetValue()) self.__read=True cat_list=self._oc.get_category_list() - with guihelper.WXDialogWrapper(common_calendar.AutoSyncFilterDialog(self, -1, 'Filtering Parameters', cat_list)) as dlg: - dlg.set(self._oc.get_filter()) - if dlg.ShowModal()==wx.ID_OK: - self._oc.set_filter(dlg.get()) + dlg=common_calendar.AutoSyncFilterDialog(self, -1, 'Filtering Parameters', cat_list) + dlg.set(self._oc.get_filter()) + if dlg.ShowModal()==wx.ID_OK: + self._oc.set_filter(dlg.get()) def GetFolder(self): return self.folderctrl.GetValue() --- bitpim-1.0.2.dfsg.1.orig/src/vcard.py +++ bitpim-1.0.2.dfsg.1/src/vcard.py @@ -11,7 +11,7 @@ VCARD is defined in RFC 2425 and 2426 """ -from __future__ import with_statement + import sys import quopri import base64 @@ -581,7 +581,7 @@ # handle a few PALM custom fields ff=field[0].split(".") f0=ff[0] - f1=ff[1] if len(ff)>1 else '' + f1=len(ff)>1 and ff[1] or '' if f0.startswith('X-PALM-CATEGORY') or f1.startswith('X-PALM-CATEGORY'): self._field_CATEGORIES(['CATEGORIES'], value, result) elif f0=='X-PALM-NICKNAME' or f1=='X-PALM-NICKNAME': @@ -593,7 +593,7 @@ def _default_field(self, field, value, result): ff=field[0].split(".") f0=ff[0] - f1=ff[1] if len(ff)>1 else '' + f1=len(ff)>1 and ff[1] or '' if f0.startswith('X-PALM-') or f1.startswith('X-PALM-'): self._field_X_PALM(field, value, result) return @@ -867,7 +867,7 @@ _pref=len(vals)>1 for v in vals: res+=out_line("TEL", - ["TYPE=%s%s" % ("PREF," if _pref else "", + ["TYPE=%s%s" % (_pref and "PREF," or "", _out_tel_mapping[v['type']])], phonenumber.format(v['number']), formatter) _pref=False @@ -997,9 +997,10 @@ except UnicodeError: common.unicode_execfile(sys.argv[1], d,d) - with file(sys.argv[2], "wt") as f: - for k in d['result']['phonebook']: - print >>f, output_entry(d['result']['phonebook'][k], profile) + f=open(sys.argv[2], "wt") + for k in d['result']['phonebook']: + print >>f, output_entry(d['result']['phonebook'][k], profile) + f.close() if len(sys.argv)==2: # import bp --- bitpim-1.0.2.dfsg.1.orig/src/newdb_wiz.py +++ bitpim-1.0.2.dfsg.1/src/newdb_wiz.py @@ -14,14 +14,12 @@ """ # system module -from __future__ import with_statement import os import os.path # wx modules import wx import wx.wizard as wiz -from wx.lib.expando import ExpandoTextCtrl # BitPim modules import bp_config @@ -68,8 +66,7 @@ vbs=wx.BoxSizer(wx.VERTICAL) vbs.Add(wx.StaticText(self, -1, 'Storage Dir:'), 0, wx.EXPAND|wx.ALL, 5) - self.path=ExpandoTextCtrl(self, -1, '', style=wx.TE_READONLY) - self.path.SetBackgroundColour(self.GetBackgroundColour()) + self.path=wx.StaticText(self, -1, '') vbs.Add(self.path, 0, wx.EXPAND|wx.ALL, 5) btn=wx.Button(self, -1, 'Browse') wx.EVT_BUTTON(self, btn.GetId(), self.OnBrowse) @@ -77,21 +74,21 @@ return vbs def ok(self): - return bool(self.path.GetValue()) + return bool(self.path.GetLabel()) def get(self, data): - data['path']=self.path.GetValue() + data['path']=self.path.GetLabel() def set(self, data): path=data.get('path', '') if not path: path=os.path.join(self.defaultdir, data.get('name', '')) - self.path.SetValue(path) + self.path.SetLabel(path) def OnBrowse(self, _): - with guihelper.WXDialogWrapper(wx.DirDialog(self, defaultPath=self.path.GetLabel(), - style=wx.DD_NEW_DIR_BUTTON), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - self.path.SetValue(dlg.GetPath()) + dlg=wx.DirDialog(self, defaultPath=self.path.GetLabel(), + style=wx.DD_NEW_DIR_BUTTON) + if dlg.ShowModal()==wx.ID_OK: + self.path.SetLabel(dlg.GetPath()) + dlg.Destroy() #------------------------------------------------------------------------------- class OptionsPage(parentpage): @@ -137,14 +134,12 @@ def GetMyControls(self): vbs=wx.StaticBoxSizer(wx.StaticBox(self, -1, 'Selection Summary:'), wx.VERTICAL) - self.summary=ExpandoTextCtrl(self, -1, '') - self.summary.SetBackgroundColour(self.GetBackgroundColour()) + self.summary=wx.StaticText(self, -1, '') vbs.Add(self.summary, 0, wx.EXPAND|wx.ALL, 5) - self._box=vbs return vbs def set(self, data): - text=['Name:\t%s'%data.get('name', '')] - text.append('Dir:\t%s'%data.get('path', '')) + text=['Name: %s'%data.get('name', '')] + text.append('Dir: %s'%data.get('path', '')) if data.get('currentsettings', False): text.append('Use current BitPim settings.') else: @@ -154,7 +149,7 @@ text.append('Create a shortcut on your Desktop.') if data.get('startmenu', False): text.append('Create a shortcut in your Start Menu.') - self.summary.SetValue('\n\n'.join(text)) + self.summary.SetLabel('\n'.join(text)) #------------------------------------------------------------------------------- class NewDBWizard(wiz.Wizard): @@ -224,26 +219,27 @@ #------------------------------------------------------------------------------- def create_new_db(parent, config=None): # Create a new BitPim Storage area - with guihelper.WXDialogWrapper(NewDBWizard(parent)) as wz: - if wz.RunWizard(): - data=wz.get() - name=data.get('name', '') - # Dir should aleady exist, but check anyway - path=data.get('path', '') - if not os.path.isdir(path): - os.makedirs(path) - # create a config file - filename=os.path.join(path, '.bitpim') - if data.get('currentsettings', False) and config: - config.write(file(filename, 'wt')) - conf=bp_config.Config(filename) - conf.Write('name', name) - # and optionally create shortcuts (Windows only) - if guihelper.IsMSWindows(): - if data.get('desktop', False): - create_desktop_shortcut(name, filename) - if data.get('startmenu', False): - create_startmenu_shortcut(name, filename) + wz=NewDBWizard(parent) + if wz.RunWizard(): + data=wz.get() + name=data.get('name', '') + # Dir should aleady exist, but check anyway + path=data.get('path', '') + if not os.path.isdir(path): + os.makedirs(path) + # create a config file + filename=os.path.join(path, '.bitpim') + if data.get('currentsettings', False) and config: + config.write(file(filename, 'wt')) + conf=bp_config.Config(filename) + conf.Write('name', name) + # and optionally create shortcuts (Windows only) + if guihelper.IsMSWindows(): + if data.get('desktop', False): + create_desktop_shortcut(name, filename) + if data.get('startmenu', False): + create_startmenu_shortcut(name, filename) + wz.Destroy() #------------------------------------------------------------------------------- # Testing --- bitpim-1.0.2.dfsg.1.orig/src/call_history.py +++ bitpim-1.0.2.dfsg.1/src/call_history.py @@ -34,7 +34,6 @@ """ # standard modules -from __future__ import with_statement import copy import sha import time @@ -294,28 +293,29 @@ current_choice=guiwidgets.HistoricalDataDialog.Historical_Data else: current_choice=guiwidgets.HistoricalDataDialog.Current_Data - with guihelper.WXDialogWrapper(guiwidgets.HistoricalDataDialog(self, - current_choice=current_choice, - historical_date=self.historical_date, - historical_events=\ - self._main_window.database.getchangescount(self._data_key)), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - with guihelper.MWBusyWrapper(self._main_window): - current_choice, self.historical_date=dlg.GetValue() - r={} - if current_choice==guiwidgets.HistoricalDataDialog.Current_Data: - self.read_only=False - msg_str='Current Data' - self.getfromfs(r) - else: - self.read_only=True - msg_str='Historical Data as of %s'%\ - str(wx.DateTimeFromTimeT(self.historical_date)) - self.getfromfs(r, self.historical_date) - self.populate(r, True) - self.historical_data_label.SetLabel(msg_str) - self.list_widget.historical_data_label.SetLabel(msg_str) + dlg=guiwidgets.HistoricalDataDialog(self, + current_choice=current_choice, + historical_date=self.historical_date, + historical_events=\ + self._main_window.database.getchangescount(self._data_key)) + if dlg.ShowModal()==wx.ID_OK: + self._main_window.OnBusyStart() + current_choice, self.historical_date=dlg.GetValue() + r={} + if current_choice==guiwidgets.HistoricalDataDialog.Current_Data: + self.read_only=False + msg_str='Current Data' + self.getfromfs(r) + else: + self.read_only=True + msg_str='Historical Data as of %s'%\ + str(wx.DateTimeFromTimeT(self.historical_date)) + self.getfromfs(r, self.historical_date) + self.populate(r, True) + self.historical_data_label.SetLabel(msg_str) + self.list_widget.historical_data_label.SetLabel(msg_str) + self._main_window.OnBusyEnd() + dlg.Destroy() def _publish_today_data(self): keys=[(x.datetime, k) for k,x in self._data.items()] --- bitpim-1.0.2.dfsg.1.orig/src/bp.py +++ bitpim-1.0.2.dfsg.1/src/bp.py @@ -15,7 +15,7 @@ @Note: Only gui mode is supported at the moment """ -from __future__ import with_statement + import sys import wx @@ -62,13 +62,14 @@ if _invalid_args: # invalid/unknown arguments try: - import guihelper _msg='%s\nUsage: %s [-c config file]|[-d config dir] [debug] [bitfling]\n'%(_error_str, sys.argv[0]) sys.stderr.write(_msg) # try to display an error message box _app=wx.PySimpleApp() - guihelper.MessageDialog(None, _msg, 'BitPim Error', - style=wx.OK|wx.ICON_ERROR) + _dlg=wx.MessageDialog(None, _msg, 'BitPim Error', + style=wx.OK|wx.ICON_ERROR) + _dlg.ShowModal() + _dlg.Destroy() finally: sys.exit(1) _kwargs={} --- bitpim-1.0.2.dfsg.1.orig/src/vcal_calendar.py +++ bitpim-1.0.2.dfsg.1/src/vcal_calendar.py @@ -10,8 +10,6 @@ "Deals with vcard calendar import stuff" # system modules -from __future__ import with_statement -import contextlib import copy import datetime @@ -22,7 +20,6 @@ import bpcalendar import bptime import common_calendar -import guihelper import helpids import vcard @@ -82,18 +79,19 @@ # no file name specified return try: - with contextlib.closing(self._open(self._file_name)) as f: - vfile=vcard.VFile(f) - has_data=False - for n,l in vfile: - if n[0]=='BEGIN' and l=='VEVENT': - has_data=True - _vdata=[] - elif n[0]=='END' and l=='VEVENT': - has_data=False - self._data.append(self._read_block(_vdata)) - elif has_data: - _vdata.append((n, l)) + f=self._open(self._file_name) + vfile=vcard.VFile(f) + has_data=False + for n,l in vfile: + if n[0]=='BEGIN' and l=='VEVENT': + has_data=True + _vdata=[] + elif n[0]=='END' and l=='VEVENT': + has_data=False + self._data.append(self._read_block(_vdata)) + elif has_data: + _vdata.append((n, l)) + f.close() except: if __debug__: raise @@ -560,36 +558,39 @@ wx.EVT_BUTTON(self, self.ID_MERGE, self.OnEndModal) wx.EVT_BUTTON(self, wx.ID_HELP, lambda *_: wx.GetApp().displayhelpid(helpids.ID_DLG_CALENDAR_IMPORT)) - @guihelper.BusyWrapper def OnImport(self, evt): - with guihelper.WXDialogWrapper(wx.ProgressDialog('%s Import'%self._data_type, - 'Importing %s Data, please wait ...'%self._data_type, - parent=self)) as dlg: - try: - self._oc.read(self.folderctrl.GetValue()) - self.populate(self._oc.get_display_data()) - except (ValueError, IOError): - guihelper.MessageDialog(self, 'Failed to get import data', - 'Import Error', - style=wx.OK|wx.ICON_ERROR) - except: - if __debug__: - raise + wx.BeginBusyCursor() + dlg=wx.ProgressDialog('%s Import'%self._data_type, + 'Importing %s Data, please wait ...'%self._data_type, + parent=self) + try: + self._oc.read(self.folderctrl.GetValue()) + self.populate(self._oc.get_display_data()) + except (ValueError, IOError): + _err_dlg=wx.MessageDialog(self, 'Failed to get import data', + 'Import Error', + style=wx.OK|wx.ICON_ERROR) + _err_dlg.ShowModal() + _err_dlg.Destroy() + except: + if __debug__: + raise + dlg.Destroy() + wx.EndBusyCursor() def OnBrowseFolder(self, evt): - with guihelper.WXDialogWrapper(wx.FileDialog(self, "Pick a %s File"%self._data_type, - wildcard='*.vcs;*.ics'), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - self.folderctrl.SetValue(dlg.GetPath()) + dlg=wx.FileDialog(self, "Pick a %s File"%self._data_type, + wildcard='*.vcs;*.ics') + if dlg.ShowModal()==wx.ID_OK: + self.folderctrl.SetValue(dlg.GetPath()) + dlg.Destroy() def OnFilter(self, evt): cat_list=self._oc.get_category_list() - with guihelper.WXDialogWrapper(common_calendar.FilterDialog(self, -1, 'Filtering Parameters', cat_list), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - self._oc.set_filter(dlg.get()) - self.populate(self._oc.get_display_data()) + dlg=common_calendar.FilterDialog(self, -1, 'Filtering Parameters', cat_list) + if dlg.ShowModal()==wx.ID_OK: + self._oc.set_filter(dlg.get()) + self.populate(self._oc.get_display_data()) def OnEndModal(self, evt): self.EndModal(evt.GetId()) @@ -645,11 +646,14 @@ main_bs.Fit(self) def OnBrowseFolder(self, evt): - with guihelper.WXDialogWrapper(wx.FileDialog(self, "Pick a VCalendar File", wildcard='*.vcs'), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - self.folderctrl.SetValue(dlg.GetPath()) - self._read=False + dlg=wx.FileDialog(self, "Pick a VCalendar File", wildcard='*.vcs') + id=dlg.ShowModal() + if id==wx.ID_CANCEL: + dlg.Destroy() + return + self.folderctrl.SetValue(dlg.GetPath()) + self._read=False + dlg.Destroy() def OnFilter(self, evt): # read the calender to get the category list @@ -657,11 +661,10 @@ self._oc.read(self.folderctrl.GetValue()) self._read=True cat_list=self._oc.get_category_list() - with guihelper.WXDialogWrapper(common_calendar.AutoSyncFilterDialog(self, -1, 'Filtering Parameters', cat_list)) \ - as dlg: - dlg.set(self._oc.get_filter()) - if dlg.ShowModal()==wx.ID_OK: - self._oc.set_filter(dlg.get()) + dlg=common_calendar.AutoSyncFilterDialog(self, -1, 'Filtering Parameters', cat_list) + dlg.set(self._oc.get_filter()) + if dlg.ShowModal()==wx.ID_OK: + self._oc.set_filter(dlg.get()) def GetFolder(self): return self.folderctrl.GetValue() --- bitpim-1.0.2.dfsg.1.orig/src/importexport.py +++ bitpim-1.0.2.dfsg.1/src/importexport.py @@ -10,8 +10,6 @@ "Deals with importing and exporting stuff" # System modules -from __future__ import with_statement -import contextlib import string import re import StringIO @@ -23,7 +21,7 @@ import wx.html # Others -from thirdparty import DSV +from DSV import DSV # My modules import common @@ -144,8 +142,10 @@ try: native.outlook.getmapinamespace() except: - guihelper.MessageDialog(None, 'Unable to initialise Outlook, Check that it is installed correctly.', - 'Outlook Error', wx.OK|wx.ICON_ERROR) + dlg=wx.MessageDialog(None, 'Unable to initialise Outlook, Check that it is installed correctly.', + 'Outlook Error', wx.OK|wx.ICON_ERROR) + dlg.ShowModal() + dlg.Destroy() return False return True @@ -674,17 +674,16 @@ if len(cats) and cats[0]=="": cats=cats[1:] self.columns,self.data=savedcolumns, saveddata - with guihelper.WXDialogWrapper(CategorySelectorDialog(self, self.categorieswanted, cats), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - self.categorieswanted=dlg.GetCategories() - if self.categorieswanted is None: - self.categorieslabel.SetLabel("*ALL*") - else: - self.categorieslabel.SetLabel("; ".join(self.categorieswanted)) - self.DataNeedsUpdate() - - @guihelper.BusyWrapper + dlg=CategorySelectorDialog(self, self.categorieswanted, cats) + if dlg.ShowModal()==wx.ID_OK: + self.categorieswanted=dlg.GetCategories() + if self.categorieswanted is None: + self.categorieslabel.SetLabel("*ALL*") + else: + self.categorieslabel.SetLabel("; ".join(self.categorieswanted)) + self.DataNeedsUpdate() + dlg.Destroy() + def UpdateData(self): "Actually update the preview data" if not self.needsupdate: @@ -736,6 +735,8 @@ self.FillPreview() + UpdateData=guihelper.BusyWrapper(UpdateData) + def _preview_format_name_none(self, row, col, names_col): # no format needed return row[col] @@ -1032,8 +1033,9 @@ column""" self.predefinedcolumns=[] for i in guihelper.getresourcefiles("*.pdc"): - with contextlib.closing(common.opentextfile(i)) as f: - self.predefinedcolumns.append(f.readline().strip()) + f=common.opentextfile(i) + self.predefinedcolumns.append(f.readline().strip()) + f.close() def OnHeaderToggle(self, _): self.columns=None @@ -1095,16 +1097,18 @@ return str=self.wcolumnsname.GetValue() for file in guihelper.getresourcefiles("*.pdc"): - with contextlib.closing(common.opentextfile(file)) as f: - desc=f.readline().strip() - if desc==str: - self.columns=map(string.strip, f.readlines()) - for i in range(len(self.columns)): - if self.columns[i] not in self.possiblecolumns: - print self.columns[i],"is not a valid column name!" - self.columns[i]="" - self.DataNeedsUpdate() - return + f=common.opentextfile(file) + desc=f.readline().strip() + if desc==str: + self.columns=map(string.strip, f.readlines()) + for i in range(len(self.columns)): + if self.columns[i] not in self.possiblecolumns: + print self.columns[i],"is not a valid column name!" + self.columns[i]="" + self.DataNeedsUpdate() + f.close() + return + f.close() print "didn't find pdc for",str def ReReadData(self): @@ -1865,105 +1869,122 @@ def OnFileImportCSVContacts(parent): - with guihelper.WXDialogWrapper(wx.FileDialog(parent, "Import CSV file", - wildcard="CSV files (*.csv)|*.csv|Tab Separated file (*.tsv)|*.tsv|All files|*", - style=wx.OPEN|wx.HIDE_READONLY|wx.CHANGE_DIR), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - path=dlg.GetPath() - else: - return + dlg=wx.FileDialog(parent, "Import CSV file", + wildcard="CSV files (*.csv)|*.csv|Tab Separated file (*.tsv)|*.tsv|All files|*", + style=wx.OPEN|wx.HIDE_READONLY|wx.CHANGE_DIR) + path=None + if dlg.ShowModal()==wx.ID_OK: + path=dlg.GetPath() + dlg.Destroy() + if path is None: + return - with guihelper.WXDialogWrapper(ImportCSVDialog(path, parent, -1, "Import CSV file"), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - data=dlg.GetFormattedData() - if data is not None: - parent.GetActivePhonebookWidget().importdata(data, merge=dlg.merge) + dlg=ImportCSVDialog(path, parent, -1, "Import CSV file") + data=None + if dlg.ShowModal()==wx.ID_OK: + data=dlg.GetFormattedData() + _merge=dlg.merge + dlg.Destroy() + if data is not None: + parent.GetActivePhonebookWidget().importdata(data, merge=_merge) def OnFileImportVCards(parent): - with guihelper.WXDialogWrapper(wx.FileDialog(parent, "Import vCards file", - wildcard="vCard files (*.vcf)|*.vcf|All files|*", - style=wx.OPEN|wx.HIDE_READONLY|wx.CHANGE_DIR), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - path=dlg.GetPath() - else: - return + dlg=wx.FileDialog(parent, "Import vCards file", + wildcard="vCard files (*.vcf)|*.vcf|All files|*", + style=wx.OPEN|wx.HIDE_READONLY|wx.CHANGE_DIR) + path=None + if dlg.ShowModal()==wx.ID_OK: + path=dlg.GetPath() + dlg.Destroy() + if path is None: + return - with guihelper.WXDialogWrapper(ImportVCardDialog(path, parent, -1, "Import vCard file"), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - data=dlg.GetFormattedData() - if data is not None: - parent.GetActivePhonebookWidget().importdata(data, merge=dlg.merge) + dlg=ImportVCardDialog(path, parent, -1, "Import vCard file") + data=None + if dlg.ShowModal()==wx.ID_OK: + data=dlg.GetFormattedData() + _merge=dlg.merge + dlg.Destroy() + if data is not None: + parent.GetActivePhonebookWidget().importdata(data, merge=_merge) def OnFileImportQtopiaDesktopContacts(parent): - with guihelper.WXDialogWrapper(ImportQtopiaDesktopDialog(parent, -1, "Import Qtopia Desktop Contacts"), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - data=dlg.GetFormattedData() - if data is not None: - parent.GetActivePhonebookWidget().importdata(data, merge=dlg.merge) + dlg=ImportQtopiaDesktopDialog(parent, -1, "Import Qtopia Desktop Contacts") + data=None + if dlg.ShowModal()==wx.ID_OK: + data=dlg.GetFormattedData() + _merge=dlg.merge + dlg.Destroy() + if data is not None: + parent.GetActivePhonebookWidget().importdata(data, merge=_merge) + def OnFileImportOutlookContacts(parent): import native.outlook if not TestOutlookIsInstalled(): return - with guihelper.WXDialogWrapper(ImportOutlookDialog(parent, -1, "Import Outlook Contacts", native.outlook), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - data=dlg.GetFormattedData() - if data is not None: - parent.GetActivePhonebookWidget().importdata(data, merge=dlg.merge) + dlg=ImportOutlookDialog(parent, -1, "Import Outlook Contacts", native.outlook) + data=None + if dlg.ShowModal()==wx.ID_OK: + data=dlg.GetFormattedData() + _merge=dlg.merge + dlg.Destroy() native.outlook.releaseoutlook() + if data is not None: + parent.GetActivePhonebookWidget().importdata(data, merge=_merge) def OnFileImportEvolutionContacts(parent): import native.evolution - with guihelper.WXDialogWrapper(ImportEvolutionDialog(parent, -1, "Import Evolution Contacts", native.evolution), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - data=dlg.GetFormattedData() - if data is not None: - parent.GetActivePhonebookWidget().importdata(data, merge=dlg.merge) + dlg=ImportEvolutionDialog(parent, -1, "Import Evolution Contacts", native.evolution) + data=None + if dlg.ShowModal()==wx.ID_OK: + data=dlg.GetFormattedData() + _merge=dlg.merge + dlg.Destroy() + if data is not None: + parent.GetActivePhonebookWidget().importdata(data, merge=_merge) def OnFileImporteGroupwareContacts(parent): import native.egroupware - with guihelper.WXDialogWrapper(ImporteGroupwareDialog(parent, -1, "Import eGroupware Contacts", native.egroupware), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - data=dlg.GetFormattedData() - if data is not None: - parent.GetActivePhonebookWidget().importdata(data, merge=dlg.merge) + dlg=ImporteGroupwareDialog(parent, -1, "Import eGroupware Contacts", native.egroupware) + data=None + if dlg.ShowModal()==wx.ID_OK: + data=dlg.GetFormattedData() + _merge=dlg.merge + dlg.Destroy() + if data is not None: + parent.GetActivePhonebookWidget().importdata(data, merge=_merge) def OnFileImportCommon(parent, dlg_class, dlg_title, widget, dict_key): - with guihelper.WXDialogWrapper(dlg_class(parent, -1, dlg_title), - True) as (dlg, res): - if res==wx.ID_OK: - pubsub.publish(pubsub.MERGE_CATEGORIES, - dlg.get_categories()[:]) - # and save the new data - data_dict={ dict_key: dlg.get() } - widget.populate(data_dict) - widget.populatefs(data_dict) - elif res==dlg_class.ID_ADD: - # ask phonebook to merge our categories - pubsub.publish(pubsub.MERGE_CATEGORIES, - dlg.get_categories()[:]) - # get existing data - data_res=widget.getdata({}).get(dict_key, {}) - # and add the new imported data - data_res.update(dlg.get()) - data_dict={ dict_key: data_res } - # and save it - widget.populate(data_dict) - widget.populatefs(data_dict) - elif res==dlg_class.ID_MERGE: - # ask phonebook to merge our categories - pubsub.publish(pubsub.MERGE_CATEGORIES, - dlg.get_categories()[:]) - # and merge the data - widget.mergedata({ dict_key: dlg.get() }) + dlg=dlg_class(parent, -1, dlg_title) + res=dlg.ShowModal() + if res==wx.ID_OK: + pubsub.publish(pubsub.MERGE_CATEGORIES, + dlg.get_categories()[:]) + # and save the new data + data_dict={ dict_key: dlg.get() } + widget.populate(data_dict) + widget.populatefs(data_dict) + elif res==dlg_class.ID_ADD: + # ask phonebook to merge our categories + pubsub.publish(pubsub.MERGE_CATEGORIES, + dlg.get_categories()[:]) + # get existing data + data_res=widget.getdata({}).get(dict_key, {}) + # and add the new imported data + data_res.update(dlg.get()) + data_dict={ dict_key: data_res } + # and save it + widget.populate(data_dict) + widget.populatefs(data_dict) + elif res==dlg_class.ID_MERGE: + # ask phonebook to merge our categories + pubsub.publish(pubsub.MERGE_CATEGORIES, + dlg.get_categories()[:]) + # and merge the data + widget.mergedata({ dict_key: dlg.get() }) + # all done + dlg.Destroy def OnFileImportOutlookCalendar(parent): import native.outlook @@ -2061,11 +2082,11 @@ return AutoConfCommon(dlg) def AutoConfCommon(dlg): - with guihelper.WXDialogWrapper(dlg, True) as (dlg, res): - if res==wx.ID_OK: - config=(dlg.GetFolder(), dlg.GetFilter()) - else: - config=() + config=() + res=dlg.ShowModal() + if res==wx.ID_OK: + config=(dlg.GetFolder(), dlg.GetFilter()) + dlg.Destroy() return res, config def AutoImportOutlookCalendar(parent, folder, filters): @@ -2101,25 +2122,27 @@ # Play list def OnWPLImport(parent): # get the wpl file name - with guihelper.WXDialogWrapper(wx.FileDialog(parent, "Import wpl file", - wildcard="wpl files (*.wpl)|*.wpl|All files|*", - style=wx.OPEN|wx.HIDE_READONLY|wx.CHANGE_DIR), - True) as (_dlg, _retcode): - # parse & retrieve the data - if _retcode==wx.ID_OK: - _wpl=wpl_file.WPL(filename=_dlg.GetPath()) - if not _wpl.title: - return - _pl_entry=playlist.PlaylistEntry() - _pl_entry.name=_wpl.title - _pl_entry.songs=[common.basename(x) for x in _wpl.songs] - # populate the new data - _widget=parent.GetActivePlaylistWidget() - _pl_data={} - _widget.getdata(_pl_data) - _pl_data[playlist.playlist_key].append(_pl_entry) - _widget.populate(_pl_data) - _widget.populatefs(_pl_data) + _dlg=wx.FileDialog(parent, "Import wpl file", + wildcard="wpl files (*.wpl)|*.wpl|All files|*", + style=wx.OPEN|wx.HIDE_READONLY|wx.CHANGE_DIR) + if _dlg.ShowModal()!=wx.ID_OK: + _dlg.Destroy() + return + # parse & retrieve the data + _wpl=wpl_file.WPL(filename=_dlg.GetPath()) + _dlg.Destroy() + if not _wpl.title: + return + _pl_entry=playlist.PlaylistEntry() + _pl_entry.name=_wpl.title + _pl_entry.songs=[common.basename(x) for x in _wpl.songs] + # populate the new data + _widget=parent.GetActivePlaylistWidget() + _pl_data={} + _widget.getdata(_pl_data) + _pl_data[playlist.playlist_key].append(_pl_entry) + _widget.populate(_pl_data) + _widget.populatefs(_pl_data) ### ### EXPORTS @@ -2259,11 +2282,11 @@ wx.EVT_BUTTON(self, wx.ID_OK, self.OnOk) def OnBrowse(self, _): - with guihelper.WXDialogWrapper(wx.FileDialog(self, defaultFile=self.filenamectrl.GetValue(), - wildcard="vCard files (*.vcf)|*.vcf", style=wx.SAVE|wx.CHANGE_DIR), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - self.filenamectrl.SetValue(os.path.join(dlg.GetDirectory(), dlg.GetFilename())) + dlg=wx.FileDialog(self, defaultFile=self.filenamectrl.GetValue(), + wildcard="vCard files (*.vcf)|*.vcf", style=wx.SAVE|wx.CHANGE_DIR) + if dlg.ShowModal()==wx.ID_OK: + self.filenamectrl.SetValue(os.path.join(dlg.GetDirectory(), dlg.GetFilename())) + dlg.Destroy() def OnOk(self, _): # do export @@ -2278,9 +2301,10 @@ assert dialect is not None # ::TODO:: ask about overwriting existing file - with file(filename, "wt") as f: - for record in self.GetPhoneBookItems(): - print >>f, vcard.output_entry(record, vcard.profiles[dialect]['profile']) + f=open(filename, "wt") + for record in self.GetPhoneBookItems(): + print >>f, vcard.output_entry(record, vcard.profiles[dialect]['profile']) + f.close() # save settings since we were succesful wx.GetApp().config.Write("vcard/export-file", filename) @@ -2328,11 +2352,11 @@ vbs.Fit(self) def OnBrowse(self, _): - with guihelper.WXDialogWrapper(wx.FileDialog(self, defaultFile=self.filenamectrl.GetValue(), - wildcard="CSV files (*.csv)|*.csv", style=wx.SAVE|wx.CHANGE_DIR), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - self.filenamectrl.SetValue(os.path.join(dlg.GetDirectory(), dlg.GetFilename())) + dlg=wx.FileDialog(self, defaultFile=self.filenamectrl.GetValue(), + wildcard="CSV files (*.csv)|*.csv", style=wx.SAVE|wx.CHANGE_DIR) + if dlg.ShowModal()==wx.ID_OK: + self.filenamectrl.SetValue(os.path.join(dlg.GetDirectory(), dlg.GetFilename())) + dlg.Destroy() def OnOk(self, _): # do export filename=self.filenamectrl.GetValue() @@ -2344,30 +2368,31 @@ for k in record: if key_count.has_key(k): key_count[k]=max(key_count[k], len(record[k])) - with file(filename, 'wt') as f: - l=[] + f=open(filename, 'wt') + l=[] + for e in self.__pb_keys: + if key_count[e[0]]: + ll=[e[0]+'_'+x for x in e[1]] + l+=ll*key_count[e[0]] + f.write(','.join(l)+'\n') + for record in self.GetPhoneBookItems(): + ll=[] for e in self.__pb_keys: - if key_count[e[0]]: - ll=[e[0]+'_'+x for x in e[1]] - l+=ll*key_count[e[0]] - f.write(','.join(l)+'\n') - for record in self.GetPhoneBookItems(): - ll=[] - for e in self.__pb_keys: - key=e[0] - if key_count[key]: - for i in range(key_count[key]): - try: - entry=record[key][i] - except (KeyError, IndexError): - entry={} - for field in e[1]: - _v=entry.get(field, '') - if isinstance(_v, unicode): - _v=_v.encode('ascii', 'ignore') - ll.append('"'+str(_v).replace('"', '')+'"') - f.write(','.join(ll)+'\n') - f.flush() + key=e[0] + if key_count[key]: + for i in range(key_count[key]): + try: + entry=record[key][i] + except (KeyError, IndexError): + entry={} + for field in e[1]: + _v=entry.get(field, '') + if isinstance(_v, unicode): + _v=_v.encode('ascii', 'ignore') + ll.append('"'+str(_v).replace('"', '')+'"') + f.write(','.join(ll)+'\n') + f.flush() + f.close() self.EndModal(wx.ID_OK) class ExporteGroupwareDialog(BaseExportDialog): @@ -2513,11 +2538,11 @@ # we check if not self.sp.doescontactexist(rec['id']): if doesntexistaction is None: - with guihelper.WXDialogWrapper(eGroupwareEntryGoneDlg(self, rec['fn']), - True) as (dlg, _): - action=dlg.GetAction() - if dlg.ForAll(): - doesntexistaction=action + dlg=eGroupwareEntryGoneDlg(self, rec['fn']) + dlg.ShowModal() + action=dlg.GetAction() + if dlg.ForAll(): + doesntexistaction=action else: action=doesntexistaction if action==self._ACTION_RECREATE: rec['id']=0 @@ -2674,50 +2699,52 @@ return self.always.GetValue() def OnFileExportVCards(parent): - with guihelper.WXDialogWrapper(ExportVCardDialog(parent, "Export phonebook to vCards"), - True): - pass + dlg=ExportVCardDialog(parent, "Export phonebook to vCards") + dlg.ShowModal() + dlg.Destroy() def OnFileExporteGroupware(parent): import native.egroupware - with guihelper.WXDialogWrapper(ExporteGroupwareDialog(parent, "Export phonebook to eGroupware", native.egroupware), - True): - pass + dlg=ExporteGroupwareDialog(parent, "Export phonebook to eGroupware", native.egroupware) + dlg.ShowModal() + dlg.Destroy() def OnFileExportCSV(parent): - with guihelper.WXDialogWrapper(ExportCSVDialog(parent, "Export phonebook to CSV"), - True): - pass + dlg=ExportCSVDialog(parent, "Export phonebook to CSV") + dlg.ShowModal() + dlg.Destroy() def OnFileExportCSVCalendar(parent): import csv_calendar - with guihelper.WXDialogWrapper(csv_calendar.ExportCSVDialog(parent, 'Export Calendar to CSV'), - True): - pass + dlg=csv_calendar.ExportCSVDialog(parent, 'Export Calendar to CSV') + dlg.ShowModal() + dlg.Destroy() def OnFileExportiCalendar(parent): - with guihelper.WXDialogWrapper(ical_calendar.ExportDialog(parent, 'Export Calendar to iCalendar'), - True): - pass + dlg=ical_calendar.ExportDialog(parent, 'Export Calendar to iCalendar') + dlg.ShowModal() + dlg.Destroy() def OnFileExportSMS(parent): import sms_imexport - with guihelper.WXDialogWrapper(sms_imexport.ExportSMSDialog(parent, 'Export SMS'), - True): - pass + dlg=sms_imexport.ExportSMSDialog(parent, 'Export SMS') + dlg.ShowModal() + dlg.Destroy() def OnFileExportCallHistory(parent): import call_history_export - with guihelper.WXDialogWrapper(call_history_export.ExportCallHistoryDialog(parent, 'Export Call History'), - True): - pass + dlg=call_history_export.ExportCallHistoryDialog(parent, 'Export Call History') + dlg.ShowModal() + dlg.Destroy() def OnFileExportMediaZip(parent): import media_root - with guihelper.WXDialogWrapper(media_root.ExportMediaToZipDialog(parent, 'Export Media to Zip')) as dlg: - dlg.DoDialog() + dlg=media_root.ExportMediaToZipDialog(parent, 'Export Media to Zip') + dlg.DoDialog() + dlg.Destroy() def OnFileExportMediaDir(parent): import media_root - with guihelper.WXDialogWrapper(media_root.ExportMediaToDirDialog(parent, 'Media will be copied to selected folder')) as dlg: - dlg.DoDialog() + dlg=media_root.ExportMediaToDirDialog(parent, 'Media will be copied to selected folder') + dlg.DoDialog() + dlg.Destroy() --- bitpim-1.0.2.dfsg.1.orig/src/filesystem.py +++ bitpim-1.0.2.dfsg.1/src/filesystem.py @@ -10,7 +10,6 @@ """The main gui code for BitPim""" # System modules -from __future__ import with_statement import ConfigParser import thread, threading import Queue @@ -279,18 +278,20 @@ pass def OnNewFile(self,_): - with guihelper.WXDialogWrapper(wx.FileDialog(self, style=wx.OPEN|wx.HIDE_READONLY|wx.CHANGE_DIR), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - infile=dlg.GetPath() - contents=open(infile, "rb").read() - if len(self.path): - path=self.path+"/"+os.path.basename(dlg.GetPath()) - else: - path=os.path.basename(dlg.GetPath()) # you can't create files in root but I won't stop you - mw=self.mainwindow - mw.MakeCall( gui.Request(mw.wt.writefile, path, contents), - gui.Callback(self.parent.OnNewFileResults, self.path) ) + dlg=wx.FileDialog(self, style=wx.OPEN|wx.HIDE_READONLY|wx.CHANGE_DIR) + if dlg.ShowModal()!=wx.ID_OK: + dlg.Destroy() + return + infile=dlg.GetPath() + contents=open(infile, "rb").read() + if len(self.path): + path=self.path+"/"+os.path.basename(dlg.GetPath()) + else: + path=os.path.basename(dlg.GetPath()) # you can't create files in root but I won't stop you + mw=self.mainwindow + mw.MakeCall( gui.Request(mw.wt.writefile, path, contents), + gui.Callback(self.parent.OnNewFileResults, self.path) ) + dlg.Destroy() def OnFileSave(self, _): path=self.itemtopath(self.GetFirstSelected()) @@ -307,11 +308,11 @@ ext="%s files (*.%s)|*.%s" % (ext.upper(), ext, ext) else: ext="All files|*" - with guihelper.WXDialogWrapper(wx.FileDialog(self, "Save File As", defaultFile=bn, wildcard=ext, - style=wx.SAVE|wx.OVERWRITE_PROMPT|wx.CHANGE_DIR), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - file(dlg.GetPath(), "wb").write(contents) + dlg=wx.FileDialog(self, "Save File As", defaultFile=bn, wildcard=ext, + style=wx.SAVE|wx.OVERWRITE_PROMPT|wx.CHANGE_DIR) + if dlg.ShowModal()==wx.ID_OK: + open(dlg.GetPath(), "wb").write(contents) + dlg.Destroy() def OnItemActivated(self,_): self.OnHexView(self) @@ -344,14 +345,16 @@ def OnFileOverwrite(self,_): path=self.itemtopath(self.GetFirstSelected()) - with guihelper.WXDialogWrapper(wx.FileDialog(self, style=wx.OPEN|wx.HIDE_READONLY|wx.CHANGE_DIR), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - infile=dlg.GetPath() - contents=open(infile, "rb").read() - mw=self.mainwindow - mw.MakeCall( gui.Request(mw.wt.writefile, path, contents), - gui.Callback(self.OnFileOverwriteResults, guihelper.dirname(path)) ) + dlg=wx.FileDialog(self, style=wx.OPEN|wx.HIDE_READONLY|wx.CHANGE_DIR) + if dlg.ShowModal()!=wx.ID_OK: + dlg.Destroy() + return + infile=dlg.GetPath() + contents=open(infile, "rb").read() + mw=self.mainwindow + mw.MakeCall( gui.Request(mw.wt.writefile, path, contents), + gui.Callback(self.OnFileOverwriteResults, guihelper.dirname(path)) ) + dlg.Destroy() def OnFileOverwriteResults(self, parentdir, exception, _): mw=self.mainwindow @@ -714,18 +717,20 @@ self.SortChildren(item) def OnNewSubdir(self, _): - with guihelper.WXDialogWrapper(wx.TextEntryDialog(self, "Subdirectory name?", "Create Subdirectory", "newfolder"), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - item=self.GetSelection() - parent=self.itemtopath(item) - if len(parent): - path=parent+"/"+dlg.GetValue() - else: - path=dlg.GetValue() - mw=self.mainwindow - mw.MakeCall( gui.Request(mw.wt.mkdir, path), - gui.Callback(self.OnNewSubdirResults, path) ) + dlg=wx.TextEntryDialog(self, "Subdirectory name?", "Create Subdirectory", "newfolder") + if dlg.ShowModal()!=wx.ID_OK: + dlg.Destroy() + return + item=self.GetSelection() + parent=self.itemtopath(item) + if len(parent): + path=parent+"/"+dlg.GetValue() + else: + path=dlg.GetValue() + mw=self.mainwindow + mw.MakeCall( gui.Request(mw.wt.mkdir, path), + gui.Callback(self.OnNewSubdirResults, path) ) + dlg.Destroy() def OnNewSubdirResults(self, new_path, exception, _): mw=self.mainwindow @@ -740,18 +745,20 @@ def OnNewFile(self,_): parent=self.itemtopath(self.GetSelection()) - with guihelper.WXDialogWrapper(wx.FileDialog(self, style=wx.OPEN|wx.HIDE_READONLY|wx.CHANGE_DIR), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - infile=dlg.GetPath() - contents=open(infile, "rb").read() - if len(parent): - path=parent+"/"+os.path.basename(dlg.GetPath()) - else: - path=os.path.basename(dlg.GetPath()) # you can't create files in root but I won't stop you - mw=self.mainwindow - mw.MakeCall( gui.Request(mw.wt.writefile, path, contents), - gui.Callback(self.OnNewFileResults, parent) ) + dlg=wx.FileDialog(self, style=wx.OPEN|wx.HIDE_READONLY|wx.CHANGE_DIR) + if dlg.ShowModal()!=wx.ID_OK: + dlg.Destroy() + return + infile=dlg.GetPath() + contents=open(infile, "rb").read() + if len(parent): + path=parent+"/"+os.path.basename(dlg.GetPath()) + else: + path=os.path.basename(dlg.GetPath()) # you can't create files in root but I won't stop you + mw=self.mainwindow + mw.MakeCall( gui.Request(mw.wt.writefile, path, contents), + gui.Callback(self.OnNewFileResults, parent) ) + dlg.Destroy() def OnNewFileResults(self, parentdir, exception, _): mw=self.mainwindow @@ -795,11 +802,11 @@ bn="root" bn+=".zip" ext="Zip files|*.zip|All Files|*" - with guihelper.WXDialogWrapper(wx.FileDialog(self, "Save File As", defaultFile=bn, wildcard=ext, - style=wx.SAVE|wx.OVERWRITE_PROMPT|wx.CHANGE_DIR), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - file(dlg.GetPath(), "wb").write(backup) + dlg=wx.FileDialog(self, "Save File As", defaultFile=bn, wildcard=ext, + style=wx.SAVE|wx.OVERWRITE_PROMPT|wx.CHANGE_DIR) + if dlg.ShowModal()==wx.ID_OK: + open(dlg.GetPath(), "wb").write(backup) + dlg.Destroy() def OnRestore(self, _): ext="Zip files|*.zip|All Files|*" @@ -809,28 +816,31 @@ bn="root" bn+=".zip" ext="Zip files|*.zip|All Files|*" - with guihelper.WXDialogWrapper(wx.FileDialog(self, "Open backup file", defaultFile=bn, wildcard=ext, - style=wx.OPEN|wx.HIDE_READONLY|wx.CHANGE_DIR), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - name=dlg.GetPath() - if not zipfile.is_zipfile(name): - with guihelper.WXDialogWrapper(guiwidgets.AlertDialogWithHelp(self.mainwindow, name+" is not a valid zipfile.", "Zip file required", - lambda _: wx.GetApp().displayhelpid(helpids.ID_NOT_A_ZIPFILE), - style=wx.OK|wx.ICON_ERROR), - True): - return - zipf=zipfile.ZipFile(name, "r") - xx=zipf.testzip() - if xx is not None: - with guihelper.WXDialogWrapper(guiwidgets.AlertDialogWithHelp(self.mainwindow, name+" has corrupted contents. Use a repair utility to fix it", - "Zip file corrupted", - lambda _: wx.GetApp().displayhelpid(helpids.ID_ZIPFILE_CORRUPTED), - style=wx.OK|wx.ICON_ERROR), - True): - return + dlg=wx.FileDialog(self, "Open backup file", defaultFile=bn, wildcard=ext, + style=wx.OPEN|wx.HIDE_READONLY|wx.CHANGE_DIR) + if dlg.ShowModal()!=wx.ID_OK: + return + name=dlg.GetPath() + if not zipfile.is_zipfile(name): + dlg=guiwidgets.AlertDialogWithHelp(self.mainwindow, name+" is not a valid zipfile.", "Zip file required", + lambda _: wx.GetApp().displayhelpid(helpids.ID_NOT_A_ZIPFILE), + style=wx.OK|wx.ICON_ERROR) + dlg.ShowModal() + dlg.Destroy() + return + zipf=zipfile.ZipFile(name, "r") + xx=zipf.testzip() + if xx is not None: + dlg=guiwidgets.AlertDialogWithHelp(self.mainwindow, name+" has corrupted contents. Use a repair utility to fix it", + "Zip file corrupted", + lambda _: wx.GetApp().displayhelpid(helpids.ID_ZIPFILE_CORRUPTED), + style=wx.OK|wx.ICON_ERROR) + dlg.ShowModal() + dlg.Destroy() + return - RestoreDialog(self.mainwindow, "Restore files", zipf, path, self.OnRestoreOK).Show(True) + dlg=RestoreDialog(self.mainwindow, "Restore files", zipf, path, self.OnRestoreOK) + dlg.Show(True) def OnRestoreOK(self, zipf, names, parentdir): if len(names)==0: --- bitpim-1.0.2.dfsg.1.orig/src/common.py +++ bitpim-1.0.2.dfsg.1/src/common.py @@ -11,9 +11,6 @@ # Documentation """Various classes and functions that are used by GUI and command line versions of BitPim""" -from __future__ import with_statement -from contextlib import contextmanager - # standard modules import string import cStringIO @@ -252,14 +249,15 @@ def writeversionindexfile(filename, dict, currentversion): assert currentversion>0 - with file(filename, 'w') as f: - for key in dict: - v=dict[key] - if isinstance(v, type({})): - f.write("result['%s']=%s\n" % (key, prettyprintdict(dict[key]))) - else: - f.write("result['%s']=%s\n" % (key, `v`)) - f.write("FILEVERSION=%d\n" % (currentversion,)) + f=open(filename, "w") + for key in dict: + v=dict[key] + if isinstance(v, type({})): + f.write("result['%s']=%s\n" % (key, prettyprintdict(dict[key]))) + else: + f.write("result['%s']=%s\n" % (key, `v`)) + f.write("FILEVERSION=%d\n" % (currentversion,)) + f.close() def formatexceptioneh(*excinfo): print formatexception(excinfo) @@ -432,15 +430,17 @@ uses the codecs module instead to open the file instead with appropriate unicode decoding, else returns the file using standard open function""" - with file(name, 'rb') as f: - start=f.read(_maxbomlen) - for bom,codec in _boms: - if start.startswith(bom): - # some codecs don't do readline, so we have to vector via stringio - # many postings also claim that the BOM is returned as the first - # character but that hasn't been the case in my testing - return StringIO.StringIO(codecs.open(name, "r", codec).read()) - return file(name, "rtU") + f=open(name, "rb") + start=f.read(_maxbomlen) + for bom,codec in _boms: + if start.startswith(bom): + f.close() + # some codecs don't do readline, so we have to vector via stringio + # many postings also claim that the BOM is returned as the first + # character but that hasn't been the case in my testing + return StringIO.StringIO(codecs.open(name, "r", codec).read()) + f.close() + return open(name, "rtU") # don't you just love i18n @@ -875,16 +875,3 @@ return HIWORD (ms), LOWORD (ms), HIWORD (ls), LOWORD (ls) except: return None - -# simple generator that generates temp file name and del it afterward -@contextmanager -def usetempfile(ext): - _name=gettempfilename(ext) - try: - yield _name - finally: - try: - os.remove(_name) - except OSError: - # ignore if failed to del temp file - pass --- bitpim-1.0.2.dfsg.1.orig/src/guihelper.py +++ bitpim-1.0.2.dfsg.1/src/guihelper.py @@ -13,8 +13,6 @@ # which confused the heck out of pychecker # standard modules -from __future__ import with_statement -import contextlib import os import glob import sys @@ -169,28 +167,6 @@ return _busywrapper -@contextlib.contextmanager -def MWBusyWrapper(mw): - mw.OnBusyStart() - try: - yield mw - finally: - mw.OnBusyEnd() - -@contextlib.contextmanager -def WXDialogWrapper(dlg, showmodal=False): - """ A wrapper for the wx.Dialog class that automatically calls Destroy""" - try: - yield (dlg, dlg.ShowModal()) if showmodal else dlg - finally: - dlg.Destroy() - -@BusyWrapper -def MessageDialog(*args, **kwargs): - with WXDialogWrapper(wx.MessageDialog(*args, **kwargs), - True): - pass - # Filename functions. These work on brew names which use forward slash / # as the directory delimiter. The builtin Python functions can't be used # as they are platform specific (eg they use \ on Windows) --- bitpim-1.0.2.dfsg.1.orig/src/guiwidgets.py +++ bitpim-1.0.2.dfsg.1/src/guiwidgets.py @@ -12,8 +12,6 @@ """Most of the graphical user interface elements making up BitPim""" # standard modules -from __future__ import with_statement -import contextlib import os import sys import time @@ -549,11 +547,20 @@ # w=self.mw.config.ReadInt("combrowsewidth", 640) # h=self.mw.config.ReadInt("combrowseheight", 480) p=self.mw.config.ReadInt("combrowsesash", 200) - with guihelper.WXDialogWrapper(CommPortDialog(self, common.importas(phones.module(self.phonebox.GetValue())), defaultport=self.commbox.GetValue(), sashposition=p), - True) as (dlg, res): - self.mw.config.WriteInt("combrowsesash", dlg.sashposition) - if res==wx.ID_OK: - self.commbox.SetValue(dlg.GetPort()) + dlg=CommPortDialog(self, common.importas(phones.module(self.phonebox.GetValue())), defaultport=self.commbox.GetValue(), sashposition=p) + # dlg.SetSize(wx.Size(w,h)) + # dlg.Centre() + res=dlg.ShowModal() + v=dlg.GetPort() + + # sz=dlg.GetSize() + # self.mw.config.WriteInt("combrowsewidth", sz.GetWidth()) + # self.mw.config.WriteInt("combrowseheight", sz.GetHeight()) + + self.mw.config.WriteInt("combrowsesash", dlg.sashposition) + dlg.Destroy() + if res==wx.ID_OK: + self.commbox.SetValue(v) def ApplyBitFlingSettings(self, _=None): if self.bitflingenabled is not None: @@ -567,10 +574,10 @@ bitflingscan.flinger.unconfigure() def OnBitFlingSettings(self, _): - with guihelper.WXDialogWrapper(BitFlingSettingsDialog(None, self.mw.config), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - dlg.SaveSettings() + dlg=BitFlingSettingsDialog(None, self.mw.config) + if dlg.ShowModal()==wx.ID_OK: + dlg.SaveSettings() + dlg.Destroy() self.ApplyBitFlingSettings() if self.mw.config.Read("bitfling/password","") \ != "": @@ -893,11 +900,11 @@ print >>html, "%s" % (desc,) print >>html, "
" print >>html, "" - with guihelper.WXDialogWrapper(wx.FileDialog(self, "Save port details as", defaultFile="bitpim-ports.html", wildcard="HTML files (*.html)|*.html", - style=wx.SAVE|wx.OVERWRITE_PROMPT|wx.CHANGE_DIR), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - file(dlg.GetPath(), "wt").write(html.getvalue()) + dlg=wx.FileDialog(self, "Save port details as", defaultFile="bitpim-ports.html", wildcard="HTML files (*.html)|*.html", + style=wx.SAVE|wx.OVERWRITE_PROMPT|wx.CHANGE_DIR) + if dlg.ShowModal()==wx.ID_OK: + open(dlg.GetPath(), "wt").write(html.getvalue()) + dlg.Destroy() def OnCancel(self, _): self.saveSize() @@ -1074,14 +1081,18 @@ try: bitflingscan.flinger.configure(*self.GetSettings()) res=bitflingscan.flinger.getversion() - guihelper.MessageDialog(self, "Succeeded. Remote version is %s" % (res,) , "Success", wx.OK|wx.ICON_INFORMATION) + dlg=wx.MessageDialog(self, "Succeeded. Remote version is %s" % (res,) , "Success", wx.OK|wx.ICON_INFORMATION) + dlg.ShowModal() + dlg.Destroy() except Exception,ex: res="Failed: %s: %s" % sys.exc_info()[:2] if hasattr(ex, "gui_exc_info"): print common.formatexception( ex.gui_exc_info) else: print common.formatexception() - guihelper.MessageDialog(self, res, "Failed", wx.OK|wx.ICON_ERROR) + dlg=wx.MessageDialog(self, res, "Failed", wx.OK|wx.ICON_ERROR) + dlg.ShowModal() + dlg.Destroy() ### @@ -1173,51 +1184,53 @@ return self._text def OnCreateReport(self, _): - with guihelper.WXDialogWrapper(CreateTroubleReportDialog(self.GetParent()), - True) as (_dlg, retcode): - if retcode==wx.ID_OK: - try: - self._create_report(_dlg.GetValue()) - guihelper.MessageDialog(self, - 'Trouble Report created successfully!', - 'BitPim Trouble Report', style=wx.OK) - except: - guihelper.MessageDialog(self, - 'Failed to Create Trouble Report', - 'Trouble Report Error', - style=wx.OK|wx.ICON_ERROR) - - def _create_report(self, vals): - with contextlib.closing(gzip.GzipFile(vals['filename'], 'wb')) as _s: - _s.write('BitPim Trouble Report\n') - _s.write(time.asctime()+'\n') - _s.write('BitPim Version: %s - %s\n'%(version.versionstring, version.vendor)) - _s.write('Platorm: %s, Architecture: %s %s, Dist: %s %s %s\n'%\ - ((platform.platform(),)+platform.architecture()+\ - platform.dist())) - # phone model if available + _dlg=CreateTroubleReportDialog(self.GetParent()) + if _dlg.ShowModal()==wx.ID_OK: try: - _model=self.GetParent().phonemodule.Phone.desc + self._create_report(_dlg.GetValue()) + _msg=wx.MessageDialog(self, + 'Trouble Report created successfully!', + 'BitPim Trouble Report', style=wx.OK) except: - _model='Not Available' - _s.write('Phone Model: %s\n'%_model) - _s.write('Name: %s\n'%vals['name']) - _s.write('email: %s\n'%vals['email']) - _s.write('Description: %s\n'%vals['description']) - _s.write('Exception:\n%s\n'%self._text) - # write out log data if evailable - try: - _log=self.GetParent().tree.lw.GetValue() - except: - # don't care if we can't get the log - _log='Not Available' - _s.write('BitPim Log:\n%s\n'%_log) - # write out protocol data if available - try: - _log=self.GetParent().tree.lwdata.GetValue() - except: - _log='Not Available' - _s.write('BitPim Protocol Data:\n%s\n'%_log) + _msg=wx.MessageDialog(self, + 'Failed to Create Trouble Report', + 'Trouble Report Error', + style=wx.OK|wx.ICON_ERROR) + _msg.ShowModal() + _msg.Destroy() + _dlg.Destroy() + def _create_report(self, vals): + _s=gzip.GzipFile(vals['filename'], 'wb') + _s.write('BitPim Trouble Report\n') + _s.write(time.asctime()+'\n') + _s.write('BitPim Version: %s - %s\n'%(version.versionstring, version.vendor)) + _s.write('Platorm: %s, Architecture: %s %s, Dist: %s %s %s\n'%\ + ((platform.platform(),)+platform.architecture()+\ + platform.dist())) + # phone model if available + try: + _model=self.GetParent().phonemodule.Phone.desc + except: + _model='Not Available' + _s.write('Phone Model: %s\n'%_model) + _s.write('Name: %s\n'%vals['name']) + _s.write('email: %s\n'%vals['email']) + _s.write('Description: %s\n'%vals['description']) + _s.write('Exception:\n%s\n'%self._text) + # write out log data if evailable + try: + _log=self.GetParent().tree.lw.GetValue() + except: + # don't care if we can't get the log + _log='Not Available' + _s.write('BitPim Log:\n%s\n'%_log) + # write out protocol data if available + try: + _log=self.GetParent().tree.lwdata.GetValue() + except: + _log='Not Available' + _s.write('BitPim Protocol Data:\n%s\n'%_log) + _s.close() class CreateTroubleReportDialog(wx.Dialog): @@ -1278,13 +1291,13 @@ wx.GetApp().displayhelpid(helpids.ID_TROUBLEREPORT) def OnBrowse(self, _): # how to select a source, default to select a file - with guihelper.WXDialogWrapper(wx.FileDialog(self, self._filename.GetValue(), - defaultFile=self._filename.GetValue(), - style=wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT, - wildcard='gzip files|*.gz'), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - self._filename.SetValue(dlg.GetPath()) + dlg=wx.FileDialog(self, self._filename.GetValue(), + defaultFile=self._filename.GetValue(), + style=wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT, + wildcard='gzip files|*.gz') + if dlg.ShowModal()==wx.ID_OK: + self._filename.SetValue(dlg.GetPath()) + dlg.Destroy() def GetValue(self): # return a dict of values of this dialog return { 'name': self._name.GetValue(), @@ -2007,9 +2020,8 @@ def OnBrowse(self, _): _dlg=wx.FileDialog(self) _dlg.SetPath(self._file_name.GetValue()) - with guihelper.WXDialogWrapper(_dlg, True) as (_dlg, retcode): - if retcode==wx.ID_OK: - self._file_name.SetValue(_dlg.GetPath()) + if _dlg.ShowModal()==wx.ID_OK: + self._file_name.SetValue(_dlg.GetPath()) def OnView(self, _): _dr_file=data_recording.DR_Read_File(self._file_name.GetValue()) @@ -2031,99 +2043,12 @@ if not data_recording.DR_Play: # not playing back, start playing self.OnPlay() - with guihelper.WXDialogWrapper(wx.SingleChoiceDialog(self, 'Select the Starting Point', - 'Data Recording Set Start', - choices=data_recording.get_headers()), - True) as (_dlg, retcode): - if retcode==wx.ID_OK: - data_recording.set_start(_dlg.GetSelection()) - -# About Dialog----------------------------------------------------------------- -_license="""The BitPim code is under the GNU General Public License as detailed -below. Specific permission is granted for this code to be linked to -OpenSSL (this is necessary because the OpenSSL license is not -GPL-compatible). - - In addition, as a special exception, the BitPim copyright holders - give permission to link the code of this program with the OpenSSL - library (or with modified versions of OpenSSL), and distribute - linked combinations including the two. You must obey the GNU - General Public License in all respects for all of the code used - other than OpenSSL. If you modify any files, you may extend this - exception to your version of the file, but you are not obligated to - do so. If you do not wish to do so, delete this exception statement - from your version. - -Please also note that some code is taken from other projects with a -GPL compatible license. This is noted in the specific files. - -BitPim also uses several other components with GPL compatible -licenses. The online help details those components, credits the -authors and details the licenses. ---------------------------------------------------------------------- -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License version 2 as published by -the Free Software Foundation. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. Also see the BitPim Help for more details -""" - -_copyright="""(C) 2003-2007 The code in BitPim is copyright by several people. Please note the -comments at the top of each file, as well as version control history. -""" -_description=""" BitPim is a program that allows you to view and manipulate data on many CDMA phones - from LG, Samsung, Sanyo and other manufacturers. This includes the PhoneBook, - Calendar, WallPapers, RingTones (functionality varies by phone) and the - Filesystem for most Qualcomm CDMA chipset based phones. To see when phones will - be supported, which ones are already supported and which features are supported, - see online help. - -[%s] -""" -def _component_string(): - """return a CSV string of various software components being used by BitPim""" - _res=[] - _str=[] - # Python version - _str.append('Python %s'%sys.version.split()[0]) - _str.append('wxPython %s'%wx.version()) - _res.append(', '.join(_str)) - _str=[] - _str.append('APSW %s'%apsw.apswversion()) - _str.append('SQLITE %s'%apsw.sqlitelibversion()) - _res.append(', '.join(_str)) - _str=[] - _str.append('serial %s'%serial.VERSION) - # pywin32 version - try: - _pywin32ver=file(os.path.join(sys.prefix,'lib','site-packages', 'pywin32.version.txt'), - 'rt').read()[:-1] - _str.append('pywin32 %s'%_pywin32ver) - except: - pass - _res.append(', '.join(_str)) - return '\n'.join(_res) - -def show_about_dlg(parent): - global _license, _copyright, _description - info = wx.AboutDialogInfo() - info.Name = "BitPim" - info.Version = version.versionstring+" - "+version.vendor - info.Copyright=_copyright - info.Description = _description%_component_string() - info.WebSite = ("http://www.bitpim.org", "www.bitpim.org") - info.Developers = [ "Joe Pham", - "Stephen Wood", - "Sean Burke", - "Nathan Hjelm", - "and others ..."] - - info.License = _license - # Then we call wx.AboutBox giving it that info object - wx.AboutBox(info) + _dlg=wx.SingleChoiceDialog(self, 'Select the Starting Point', + 'Data Recording Set Start', + choices=data_recording.get_headers()) + if _dlg.ShowModal()==wx.ID_OK: + data_recording.set_start(_dlg.GetSelection()) + _dlg.Destroy() # Generic Print Dialog---------------------------------------------------------- class PrintDialog(wx.Dialog): @@ -2155,7 +2080,7 @@ vbs.Add(wx.StaticLine(self, -1), 0, wx.EXPAND|wx.TOP|wx.BOTTOM, 5) hbs=wx.BoxSizer(wx.HORIZONTAL) for b in ((None, wx.ID_PRINT, self.OnPrint), - ('Page Setup', wx.ID_PAGE_SETUP, self.OnPageSetup), + ('Page Setup', wx.ID_PRINT_SETUP, self.OnPageSetup), (None, wx.ID_PREVIEW, self.OnPrintPreview), ('Save as HTML', -1, self.OnSaveHTML), (None, wx.ID_CLOSE, self.OnClose)): @@ -2214,12 +2139,12 @@ self._gen_print_data() wx.GetApp().htmlprinter.PreviewText(self._html) def OnSaveHTML(self, _): - with guihelper.WXDialogWrapper(wx.FileDialog(self, wildcard="Web Page (*.htm;*.html)|*.htm;*html", - style=wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT), - True) as (_dlg, retcode): - if retcode==wx.ID_OK: - self._gen_print_data() - file(_dlg.GetPath(), 'wt').write(self._html) + _dlg=wx.FileDialog(self, wildcard="Web Page (*.htm;*.html)|*.htm;*html", + style=wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) + if _dlg.ShowModal()==wx.ID_OK: + self._gen_print_data() + file(_dlg.GetPath(), 'wt').write(self._html) + _dlg.Destroy() def OnClose(self, _): try: # remove the temp file, ignore exception if file does not exist --- bitpim-1.0.2.dfsg.1.orig/src/comm_notify.py +++ bitpim-1.0.2.dfsg.1/src/comm_notify.py @@ -14,6 +14,7 @@ import signal import sys +import ctypes import wx bpCOMM_NOTIFICATION_EVENT = wx.NewEventType() @@ -58,8 +59,8 @@ self.mw.OnCommNotification(self.evt) return True -NotificationPath='/var/bitpim' -NotificationFile='/var/bitpim/dnotify.log' +NotificationPath='/var/run/bitpim' +NotificationFile='/var/run/bitpim/dnotify.log' def _process_notification(commobj): # read the log file & process its content @@ -98,8 +99,10 @@ if __debug__: raise return False - fcntl.fcntl(_global_fd, fcntl.F_NOTIFY, - fcntl.DN_MODIFY|fcntl.DN_CREATE|fcntl.DN_MULTISHOT) + flags=fcntl.DN_MODIFY|fcntl.DN_CREATE|fcntl.DN_MULTISHOT + # The business with ctypes ensures that fcntl's argument fits into + # a C integer, which might not otherwise occur on 64-bit systems. + fcntl.fcntl(_global_fd, fcntl.F_NOTIFY, ctypes.c_int(flags).value) mainwindow.log('USB Comm Watch started') return True --- bitpim-1.0.2.dfsg.1.orig/src/t9editor.py +++ bitpim-1.0.2.dfsg.1/src/t9editor.py @@ -34,13 +34,11 @@ """ # wx Modules -from __future__ import with_statement import wx import wx.gizmos as gizmos # BitPim modules import database -import guihelper import helpids import widgets @@ -276,15 +274,14 @@ def CanAdd(self): return True def OnAdd(self, _): - with guihelper.WXDialogWrapper(wx.TextEntryDialog(self, 'Enter a new word:', - 'T9 User Word'), - True) as (_dlg, _retcode): - if _retcode==wx.ID_OK: - if _dlg.GetValue(): - self.OnMakeDirty() - self._t9list.append_word(_dlg.GetValue()) - self._populate() - + _dlg=wx.TextEntryDialog(self, 'Enter a new word:', + 'T9 User Word') + if _dlg.ShowModal()==wx.ID_OK: + if _dlg.GetValue(): + self.OnMakeDirty() + self._t9list.append_word(_dlg.GetValue()) + self._populate() + _dlg.Destroy() def CanDelete(self): return self._words_lb.GetSelectedItemCount() def OnDelete(self, _): --- bitpim-1.0.2.dfsg.1.orig/src/media_root.py +++ bitpim-1.0.2.dfsg.1/src/media_root.py @@ -8,8 +8,6 @@ # standard modules -from __future__ import with_statement -import contextlib import os import cStringIO import copy @@ -161,8 +159,9 @@ me=widget._data[item.datakey][item.key] if me.mediadata!=None and me.mediadata!='': fpath=self._main_window._fixup(os.path.join(opath, me.name)) - with file(fpath, "wb") as f: - f.write(me.mediadata) + f=open(fpath, "wb") + f.write(me.mediadata) + f.close() if me.timestamp!=None: os.utime(fpath, (me.timestamp, me.timestamp)) @@ -171,12 +170,13 @@ # create the zipfile in a buffer # and write to disk after it is all created op=cStringIO.StringIO() - with contextlib.closing(zipfile.ZipFile(op, "w", zipfile.ZIP_DEFLATED)) as zip: - if self.widget_to_save==None: - self.SaveWidgetToZip(zip, self.ringerwidget) - self.SaveWidgetToZip(zip, self.wallpaperwidget) - else: - self.SaveWidgetToZip(zip, self.widget_to_save, self.origin_to_save) + zip=zipfile.ZipFile(op, "w", zipfile.ZIP_DEFLATED) + if self.widget_to_save==None: + self.SaveWidgetToZip(zip, self.ringerwidget) + self.SaveWidgetToZip(zip, self.wallpaperwidget) + else: + self.SaveWidgetToZip(zip, self.widget_to_save, self.origin_to_save) + zip.close() open(zip_file, "wb").write(op.getvalue()) def SaveWidgetToZip(self, zip, widget, filter=""): --- bitpim-1.0.2.dfsg.1.orig/src/database.py +++ bitpim-1.0.2.dfsg.1/src/database.py @@ -8,7 +8,7 @@ ### $Id: database.py 4370 2007-08-21 21:39:36Z djpham $ """Interface to the database""" -from __future__ import with_statement + import os import copy import time @@ -232,9 +232,13 @@ ### -# Change this to True to see what is going on under the hood. It -# will produce a lot of output! -TRACE=False +if __debug__: + # Change this to True to see what is going on under the hood. It + # will produce a lot of output! + TRACE=False +else: + TRACE=False + def ExclusiveWrapper(method): """Wrap a method so that it has an exclusive lock on the database @@ -242,15 +246,48 @@ # note that the existing threading safety checks in apsw will # catch any thread abuse issues. + + def _transactionwrapper(*args, **kwargs): - # arg[0] should be a Database instance - assert isinstance(args[0], Database) - with args[0]: - return method(*args, **kwargs) + # nb self is the Database instance + self=args[0] + self.excounter+=1 + self.transactionwrite=False + if self.excounter==1: + if TRACE: + print "BEGIN EXCLUSIVE TRANSACTION" + self.cursor.execute("BEGIN EXCLUSIVE TRANSACTION") + self._schemacache={} + try: + try: + success=True + return method(*args, **kwargs) + except: + success=False + raise + finally: + self.excounter-=1 + if self.excounter==0: + w=self.transactionwrite + if success: + if w: + cmd="COMMIT TRANSACTION" + else: + cmd="END TRANSACTION" + else: + if w: + cmd="ROLLBACK TRANSACTION" + else: + cmd="END TRANSACTION" + if TRACE: + print cmd + self.cursor.execute(cmd) + setattr(_transactionwrapper, "__doc__", getattr(method, "__doc__")) return _transactionwrapper + def sqlquote(s): "returns an sqlite quoted string (the return value will begin and end with single quotes)" return "'"+s.replace("'", "''")+"'" @@ -265,31 +302,6 @@ class Database: - # Make this class a context manager so it can be used with WITH blocks - def __enter__(self): - self.excounter+=1 - self.transactionwrite=False - if self.excounter==1: - if TRACE: - print "BEGIN EXCLUSIVE TRANSACTION" - self.cursor.execute("BEGIN EXCLUSIVE TRANSACTION") - self._schemacache={} - return self - - def __exit__(self, ex_type, ex_value, tb): - self.excounter-=1 - if self.excounter==0: - w=self.transactionwrite - if tb is None: - # no exception, so commit - cmd="COMMIT TRANSACTION" if w else "END TRANSACTION" - else: - # an exception occurred, so rollback - cmd="ROLLBACK TRANSACTION" if w else "END TRANSACTION" - if TRACE: - print cmd - self.cursor.execute(cmd) - def __del__(self): # connections have to be closed now self.connection.close(True) @@ -381,7 +393,6 @@ return [name for colnum,name,type in res] return res - @ExclusiveWrapper def savemajordict(self, tablename, dict, timestamp=None): """This is the entrypoint for saving a first level dictionary such as the phonebook or calendar. @@ -596,10 +607,9 @@ res+=`found`+"," indirects[r]=res - @ExclusiveWrapper + def getmajordictvalues(self, tablename, factory=dictdataobjectfactory, at_time=None): - if not self.doestableexist(tablename): return {} @@ -723,7 +733,6 @@ self.sql(" ".join(cmd)) self.sql("drop table "+idquote("backup_"+tablename)) - @ExclusiveWrapper def deleteold(self, tablename, uids=None, minvalues=3, maxvalues=5, keepoldest=93): """Deletes old entries from the database. The deletion is based on either criterion of maximum values or age of values matching. @@ -778,7 +787,6 @@ return len(deleterows), self.sql("select count(*) from "+idquote(tablename)).next()[0] - @ExclusiveWrapper def savelist(self, tablename, values): """Just save a list of items (eg categories). There is no versioning or transaction history. @@ -820,14 +828,19 @@ vv.sort() assert vdup==vv - @ExclusiveWrapper def loadlist(self, tablename): """Loads a list of items (eg categories)""" if not self.doestableexist(tablename): return [] return [v[0] for v in self.sql("select item from %s where __deleted__=0" % (idquote(tablename),))] - @ExclusiveWrapper + # various operations need exclusive access to the database + savemajordict=ExclusiveWrapper(savemajordict) + getmajordictvalues=ExclusiveWrapper(getmajordictvalues) + deleteold=ExclusiveWrapper(deleteold) + savelist=ExclusiveWrapper(savelist) + loadlist=ExclusiveWrapper(loadlist) + def getchangescount(self, tablename): """Return the number of additions, deletions, and modifications made to this table over time. --- bitpim-1.0.2.dfsg.1.orig/src/memo.py +++ bitpim-1.0.2.dfsg.1/src/memo.py @@ -47,7 +47,6 @@ """ # standard modules -from __future__ import with_statement import copy import datetime import time @@ -514,6 +513,8 @@ def _OnSave(self, evt): # save the current changes self.ignoredirty=True + # Enable the list to get the selection + self._item_list.Enable() sel_idx=self._item_list.GetSelection() k=self._item_list.GetClientData(sel_idx) entry=self._data[k] @@ -540,8 +541,8 @@ self.setdirty(False) def OnPrintDialog(self, mainwindow, config): - with guihelper.WXDialogWrapper(guiwidgets.MemoPrintDialog(self, mainwindow, config), - True): - pass + dlg=guiwidgets.MemoPrintDialog(self, mainwindow, config) + dlg.ShowModal() + dlg.Destroy() def CanPrint(self): return True --- bitpim-1.0.2.dfsg.1.orig/src/imp_cal_preset.py +++ bitpim-1.0.2.dfsg.1/src/imp_cal_preset.py @@ -13,7 +13,6 @@ """ # System -from __future__ import with_statement import calendar import copy import datetime @@ -156,11 +155,11 @@ return gs def _OnFilter(self, _): - with guihelper.WXDialogWrapper(FilterDialog(self, -1, 'Filtering Parameters', self._data), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - self._data.update(dlg.get()) - self._populate() + dlg=FilterDialog(self, -1, 'Filtering Parameters', self._data) + if dlg.ShowModal()==wx.ID_OK: + self._data.update(dlg.get()) + self._populate() + dlg.Destroy() def _display(self, key, attr, fmt): # display the value field of this key @@ -335,15 +334,16 @@ def _preview_data(self): # Display a preview of data just imported - with guihelper.WXDialogWrapper(CalendarPreviewDialog(self, self._import_data.get()), - True) as (_dlg, _ret_code): - if _ret_code==CalendarPreviewDialog.ID_REPLACE: - return wx.ID_OK - elif _ret_code==CalendarPreviewDialog.ID_ADD: - return self.ID_ADD - elif _ret_code==CalendarPreviewDialog.ID_MERGE: - return self.ID_MERGE - return wx.ID_CANCEL + _dlg=CalendarPreviewDialog(self, self._import_data.get()) + _ret_code=_dlg.ShowModal() + _dlg.Destroy() + if _ret_code==CalendarPreviewDialog.ID_REPLACE: + return wx.ID_OK + elif _ret_code==CalendarPreviewDialog.ID_ADD: + return self.ID_ADD + elif _ret_code==CalendarPreviewDialog.ID_MERGE: + return self.ID_MERGE + return wx.ID_CANCEL def _get_preset_thisweek(self): # return the dates of (today, Sat) @@ -385,7 +385,6 @@ '_get_preset_thismonth', '_get_preset_thisyear', '_get_preset_next7'][_preset_date])() - @guihelper.BusyWrapper def _OnRun(self, _): _idx=self._name_lb.GetSelection() if _idx==wx.NOT_FOUND: @@ -400,12 +399,15 @@ self._import_data=_info['data']() _source=_info['source']() _source.id=_entry['source_id'] - with guihelper.WXDialogWrapper(wx.ProgressDialog('Calendar Data Import', - 'Importing data, please wait ...', - parent=self)) as _dlg: - self._import_data.read(_source.get(), _dlg) - self._adjust_filter_dates(_entry) - self._import_data.set_filter(_entry) + wx.BeginBusyCursor() + _dlg=wx.ProgressDialog('Calendar Data Import', + 'Importing data, please wait ...', + parent=self) + self._import_data.read(_source.get(), _dlg) + self._adjust_filter_dates(_entry) + self._import_data.set_filter(_entry) + _dlg.Destroy() + wx.EndBusyCursor() global IMP_OPTION_PREVIEW, IMP_OPTION_REPLACEALL, IMP_OPTION_ADD, IMP_OPTION_MERGE _option=_entry.get('option', IMP_OPTION_PREVIEW) if _option==IMP_OPTION_PREVIEW: @@ -420,27 +422,27 @@ def _OnNew(self, _): _entry=ImportCalendarEntry() - with guihelper.WXDialogWrapper(ImportCalendarPresetWizard(self, _entry)) \ - as _wiz: - if _wiz.RunWizard(): - _entry=_wiz.get() - self._data[_entry.id]=_entry - self._save_to_fs() - self._populate() + _wiz=ImportCalendarPresetWizard(self, _entry) + if _wiz.RunWizard(): + _entry=_wiz.get() + self._data[_entry.id]=_entry + self._save_to_fs() + self._populate() + _wiz.Destroy() def _OnEdit(self, _): _idx=self._name_lb.GetSelection() if _idx==wx.NOT_FOUND: return _key=self._name_lb.GetClientData(_idx) _entry=self._data[_key].copy() - with guihelper.WXDialogWrapper(ImportCalendarPresetWizard(self, _entry)) \ - as _wiz: - if _wiz.RunWizard(): - _entry=ImportCalendarEntry(_wiz.get()) - del self._data[_key] - self._data[_entry.id]=_entry - self._save_to_fs() - self._populate() + _wiz=ImportCalendarPresetWizard(self, _entry) + if _wiz.RunWizard(): + _entry=ImportCalendarEntry(_wiz.get()) + del self._data[_key] + self._data[_entry.id]=_entry + self._save_to_fs() + self._populate() + _wiz.Destroy() def _OnDel(self, _): _idx=self._name_lb.GetSelection() if _idx==wx.NOT_FOUND: @@ -530,7 +532,7 @@ f=wx.Frame(None, title='imp_cal_preset') _data=ImportCalendarEntry() _data.id - with guihelper.WXDialogWrapper(ImportCalendarPresetWizard(f, _data)) \ - as w: - print 'RunWizard:',w.RunWizard() - print 'Data:',w.get() + w=ImportCalendarPresetWizard(f, _data) + print 'RunWizard:',w.RunWizard() + print 'Data:',w.get() + w.Destroy() --- bitpim-1.0.2.dfsg.1.orig/src/calendarentryeditor.py +++ bitpim-1.0.2.dfsg.1/src/calendarentryeditor.py @@ -7,7 +7,6 @@ ### ### $Id: calendarentryeditor.py 4397 2007-09-13 01:26:23Z djpham $ -from __future__ import with_statement import calendar import copy import datetime @@ -371,8 +370,10 @@ end=datetime.datetime(*self._w['end'].GetValue()) if start>end: # scold the user - guihelper.MessageDialog(self, "End date and time is before start!", "Time Travel Attempt Detected", - wx.OK|wx.ICON_EXCLAMATION) + dlg=wx.MessageDialog(self, "End date and time is before start!", "Time Travel Attempt Detected", + wx.OK|wx.ICON_EXCLAMATION) + dlg.ShowModal() + dlg.Destroy() # move focus self._w['end'].SetFocus() return False @@ -472,9 +473,8 @@ hs.Fit(self) def OnManageCategories(self, _): - with guihelper.WXDialogWrapper(pb_editor.CategoryManager(self), - True): - pass + dlg=pb_editor.CategoryManager(self) + dlg.ShowModal() def OnUpdateCategories(self, msg): cats=msg.data[:] @@ -977,15 +977,16 @@ return self._AskAboutRecurringEvent("Change recurring event?", "Do you want to change all the recurring events, or just this one?", "Change") def _AskAboutRecurringEvent(self, caption, text, prefix): - with guihelper.WXDialogWrapper(RecurringDialog(self, caption, text, prefix), - True) as (dlg, res): - if res==dlg.ID_THIS: - return self.ANSWER_THIS - if res==dlg.ID_ALL: - return self.ANSWER_ORIGINAL - if res==dlg.ID_CANCEL: - return self.ANSWER_CANCEL - assert False + dlg=RecurringDialog(self, caption, text, prefix) + res=dlg.ShowModal() + dlg.Destroy() + if res==dlg.ID_THIS: + return self.ANSWER_THIS + if res==dlg.ID_ALL: + return self.ANSWER_ORIGINAL + if res==dlg.ID_CANCEL: + return self.ANSWER_CANCEL + assert False #------------------------------------------------------------------------------ # We derive from wxPanel not the control directly. If we derive from # wx.MaskedTextCtrl then all hell breaks loose as our {Get|Set}Value --- bitpim-1.0.2.dfsg.1.orig/src/gcal_calendar.py +++ bitpim-1.0.2.dfsg.1/src/gcal_calendar.py @@ -10,7 +10,6 @@ "Deals with Google Calendar (gCalendar) import stuff" # system modules -from __future__ import with_statement import urllib2 # site modules @@ -19,7 +18,6 @@ # local modules import common_calendar import database -import guihelper import ical_calendar as ical import vcal_calendar as vcal @@ -35,11 +33,11 @@ if parent is None or not hasattr(parent, 'GetActiveDatabase'): # need the database return - with guihelper.WXDialogWrapper(SelectURLDialog(parent, self.message_str, - parent.GetActiveDatabase()), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - self._source=dlg.GetPath() + dlg=SelectURLDialog(parent, self.message_str, + parent.GetActiveDatabase()) + if dlg.ShowModal()==wx.ID_OK: + self._source=dlg.GetPath() + dlg.Destroy() #------------------------------------------------------------------------------- URLDictKey='URLs' @@ -79,10 +77,10 @@ super(gCalImportDialog, self).__init__(parent, id, title) def OnBrowseFolder(self, _): - with guihelper.WXDialogWrapper(SelectURLDialog(self, 'Select a Google Calendar iCal URL', self._db), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - self.folderctrl.SetValue(dlg.GetPath()) + dlg=SelectURLDialog(self, 'Select a Google Calendar iCal URL', self._db) + if dlg.ShowModal()==wx.ID_OK: + self.folderctrl.SetValue(dlg.GetPath()) + dlg.Destroy() #------------------------------------------------------------------------------- class SelectURLDialog(wx.Dialog): @@ -132,14 +130,14 @@ del self._data[_idx] self._save_to_fs(self._data) def OnNew(self, _): - with guihelper.WXDialogWrapper(NewURLDialog(self), - True) as (_dlg, retcode): - if retcode==wx.ID_OK: - _name, _url=_dlg.get() - self._choices.Append(_name, _url) - self._data.append({ 'name': _name, - 'url': _url }) - self._save_to_fs(self._data) + _dlg=NewURLDialog(self) + if _dlg.ShowModal()==wx.ID_OK: + _name, _url=_dlg.get() + self._choices.Append(_name, _url) + self._data.append({ 'name': _name, + 'url': _url }) + self._save_to_fs(self._data) + _dlg.Destroy() def OnOK(self, evt): self.EndModal(wx.ID_OK) def GetPath(self): --- bitpim-1.0.2.dfsg.1.orig/src/todo.py +++ bitpim-1.0.2.dfsg.1/src/todo.py @@ -51,7 +51,6 @@ """ # standard modules -from __future__ import with_statement import copy import datetime import time @@ -65,7 +64,6 @@ # BitPim modules import calendarentryeditor as cal_editor import database -import guihelper import helpids import field_color import phonebookentryeditor as pb_editor @@ -349,16 +347,16 @@ dt=datetime.date.today() else: dt=self._dt - with guihelper.WXDailogWrapper(wx.lib.calendar.CalenDlg(self, - month=dt.month, - day=dt.day, - year=dt.year)) as dlg: - dlg.Centre() - if dlg.ShowModal() == wx.ID_OK: - self._dt=datetime.date(dlg.calend.GetYear(), - dlg.calend.GetMonth(), - dlg.calend.GetDay()) - self._refresh() + dlg = wx.lib.calendar.CalenDlg(self, + month=dt.month, + day=dt.day, + year=dt.year) + dlg.Centre() + if dlg.ShowModal() == wx.ID_OK: + self._dt=datetime.date(dlg.calend.GetYear(), + dlg.calend.GetMonth(), + dlg.calend.GetDay()) + self._refresh() def SetValue(self, v): # set a date string from the dict if v is None or not len(v): @@ -723,6 +721,8 @@ def _OnSave(self, evt): # save the current changes self.ignoredirty=True + # Enable the list to get the selection + self._item_list.Enable() sel_idx=self._item_list.GetSelection() k=self._item_list.GetClientData(sel_idx) entry=self._data[k] --- bitpim-1.0.2.dfsg.1.orig/src/gui.py +++ bitpim-1.0.2.dfsg.1/src/gui.py @@ -10,8 +10,6 @@ """The main gui code for BitPim""" # System modules -from __future__ import with_statement -import contextlib import thread, threading import Queue import time @@ -324,23 +322,6 @@ _NotSafeObject=_NotSafeObject() -class Event(object): - """Simple Event class that supports Context Manager""" - def __init__(self): - self._event=threading.Event() - def __enter__(self): - self._event.set() - def __exit__(self, exc_type, exc_value, tb): - self._event.clear() - def set(self): - return self._event.set() - def clear(self): - return self._event.clear() - def isSet(self): - return self._event.isSet() - def wait(self, timeout=None): - return self._event.wait(timeout) - EVT_CALLBACK=None class MainApp(wx.App): def __init__(self, argv, config_filename=None): @@ -348,8 +329,6 @@ self.SAFEMODE=False codecs.register(phone_media_codec.search_func) self._config_filename=config_filename - # simple Event object to flag when entering/leaving critical section - self.critical=Event() wx.App.__init__(self, redirect=False, useBestVisual=not guihelper.IsGtk()) @@ -396,9 +375,10 @@ self.config=bp_config.Config(self._config_filename) # Check to see if we're the 2nd instance running on the same DB if self.usingsamedb(): - guihelper.MessageDialog(None, 'Another copy of BitPim is using the same data dir:\n%s'%self.config._path, - 'BitPim Error', - style=wx.OK|wx.ICON_ERROR) + wx.MessageDialog(None, + 'Another copy of BitPim is using the same data dir:\n%s'%self.config._path, + 'BitPim Error', + style=wx.OK|wx.ICON_ERROR).ShowModal() return False # this is for wx native use, like the freaking help controller ! self.wxconfig=wx.Config(cfgstr, style=wx.CONFIG_USE_LOCAL_FILE) @@ -1079,10 +1059,8 @@ # deal with configuring the phone (commport) def OnEditSettings(self, _=None): if wx.IsBusy(): - with guihelper.WXDialogWrapper(wx.MessageBox("BitPim is busy. You can't change settings until it has finished talking to your phone.", - "BitPim is busy.", wx.OK|wx.ICON_EXCLAMATION), - True): - pass + wx.MessageBox("BitPim is busy. You can't change settings until it has finished talking to your phone.", + "BitPim is busy.", wx.OK|wx.ICON_EXCLAMATION) else: # clear the ower's name for manual setting self.__owner_name='' @@ -1090,7 +1068,13 @@ # about and help def OnHelpAbout(self,_): - guiwidgets.show_about_dlg(self) + import version + + str="BitPim Version "+version.versionstring+" - "+version.vendor + + d=wx.MessageDialog(self, str, "About BitPim", wx.OK|wx.ICON_INFORMATION) + d.ShowModal() + d.Destroy() def OnHelpHelp(self, _): wx.GetApp().displayhelpid(self.GetCurrentActiveWidget().GetHelpID()) @@ -1155,8 +1139,8 @@ "Phone Info Error", style=wx.OK) else: dlg=phoneinfo.PhoneInfoDialog(self, phone_info) - with guihelper.WXDialogWrapper(dlg, True): - pass + dlg.ShowModal() + dlg.Destroy() def OnDetectPhone(self, _=None): if wx.IsBusy(): @@ -1204,17 +1188,19 @@ s=None if phone_name=='': # not seen before - with guihelper.WXDialogWrapper(guiwidgets.AskPhoneNameDialog(self, 'A new phone has been detected,\n' - "Would you like to enter the owner's name:", style=style), - True) as (dlg, r): - if r==wx.ID_OK: - # user gave a name - s=dlg.GetValue() - elif r==wx.ID_CANCEL: - s='' - if s is not None: - self.config.Write(phone_id, s) - return s + dlg=guiwidgets.AskPhoneNameDialog( + self, 'A new phone has been detected,\n' + "Would you like to enter the owner's name:", style=style) + r=dlg.ShowModal() + if r==wx.ID_OK: + # user gave a name + s=dlg.GetValue() + elif r==wx.ID_CANCEL: + s='' + if s is not None: + self.config.Write(phone_id, s) + dlg.Destroy() + return s return phone_name def OnDetectPhoneReturn(self, check_auto_sync, silent_fail, exception, r): @@ -1224,12 +1210,12 @@ if r is None: if not silent_fail: self.__owner_name='' - with guihelper.WXDialogWrapper(wx.MessageDialog(self, 'No phone detected/recognized.\nRun Settings?', - 'Phone Detection Failed', wx.YES_NO), - True) as (_dlg, retcode): - if retcode==wx.ID_YES: - wx.CallAfter(self.OnEditSettings) - self.SetPhoneModelStatus(guiwidgets.SB_Phone_Set) + _dlg=wx.MessageDialog(self, 'No phone detected/recognized.\nRun Settings?', + 'Phone Detection Failed', wx.YES_NO) + if _dlg.ShowModal()==wx.ID_YES: + wx.CallAfter(self.OnEditSettings) + _dlg.Destroy() + self.SetPhoneModelStatus(guiwidgets.SB_Phone_Set) else: if silent_fail: self.__owner_name=None @@ -1367,96 +1353,94 @@ return self._autodetect_delay=self.phoneprofile.autodetect_delay todo.append((self.wt.rebootcheck, "Phone Reboot")) - wx.GetApp().critical.set() self.MakeCall(Request(self.wt.getdata, dlg, todo), Callback(self.OnDataGetPhoneResults)) def OnDataGetPhoneResults(self, exception, results): - with wx.GetApp().critical: - if self.HandleException(exception): return - self.OnLog(`results.keys()`) - self.OnLog(`results['sync']`) - # phonebook - if results['sync'].has_key('phonebook'): - v=results['sync']['phonebook'] - - print "phonebookmergesetting is",v - if v=='MERGE': - merge=True - else: - merge=False - self.GetActivePhonebookWidget().importdata(results['phonebook'], results.get('categories', []), merge) + if self.HandleException(exception): return + self.OnLog(`results.keys()`) + self.OnLog(`results['sync']`) + # phonebook + if results['sync'].has_key('phonebook'): + v=results['sync']['phonebook'] + + print "phonebookmergesetting is",v + if v=='MERGE': + merge=True + else: + merge=False + self.GetActivePhonebookWidget().importdata(results['phonebook'], results.get('categories', []), merge) - # wallpaper - updwp=False # did we update the wallpaper - if results['sync'].has_key('wallpaper'): - v=results['sync']['wallpaper'] - if v=='MERGE': raise Exception("Not implemented") - updwp=True - self.GetActiveWallpaperWidget().populatefs(results) - self.GetActiveWallpaperWidget().populate(results) - # wallpaper-index - if not updwp and results.has_key('wallpaper-index'): - self.GetActiveWallpaperWidget().updateindex(results) - # ringtone - updrng=False # did we update ringtones - if results['sync'].has_key('ringtone'): - v=results['sync']['ringtone'] - if v=='MERGE': raise Exception("Not implemented") - updrng=True - self.GetActiveRingerWidget().populatefs(results) - self.GetActiveRingerWidget().populate(results) - # ringtone-index - if not updrng and results.has_key('ringtone-index'): - self.GetActiveRingerWidget().updateindex(results) - # calendar - if results['sync'].has_key('calendar'): - v=results['sync']['calendar'] - if v=='MERGE': raise Exception("Not implemented") - results['calendar_version']=self.phoneprofile.BP_Calendar_Version - self.GetActiveCalendarWidget().mergedata(results) - ## self.GetActiveCalendarWidget().populatefs(results) - ## self.GetActiveCalendarWidget().populate(results) - # memo - if results['sync'].has_key('memo'): - v=results['sync']['memo'] - if v=='MERGE': raise Exception("Not implemented") - self.GetActiveMemoWidget().populatefs(results) - self.GetActiveMemoWidget().populate(results) - # todo - if results['sync'].has_key('todo'): - v=results['sync']['todo'] - if v=='MERGE': raise NotImplementedError - self.GetActiveTodoWidget().populatefs(results) - self.GetActiveTodoWidget().populate(results) - # SMS - if results['sync'].has_key('sms'): - v=results['sync']['sms'] - if v=='MERGE': - self.GetActiveSMSWidget().merge(results) - else: - self.GetActiveSMSWidget().populatefs(results) - self.GetActiveSMSWidget().populate(results) - # call history - if results['sync'].has_key('call_history'): - v=results['sync']['call_history'] - if v=='MERGE': - self.GetActiveCallHistoryWidget().merge(results) - else: - self.GetActiveCallHistoryWidget().populatefs(results) - self.GetActiveCallHistoryWidget().populate(results) - # Playlist - if results['sync'].has_key(playlist.playlist_key): - if results['sync'][playlist.playlist_key]=='MERGE': - raise NotImplementedError - self.GetActivePlaylistWidget().populatefs(results) - self.GetActivePlaylistWidget().populate(results) - # T9 User DB - if results['sync'].has_key(t9editor.dict_key): - if results['sync'][t9editor.dict_key]=='MERGE': - raise NotImplementedError - self.GetActiveT9EditorWidget().populatefs(results) - self.GetActiveT9EditorWidget().populate(results) + # wallpaper + updwp=False # did we update the wallpaper + if results['sync'].has_key('wallpaper'): + v=results['sync']['wallpaper'] + if v=='MERGE': raise Exception("Not implemented") + updwp=True + self.GetActiveWallpaperWidget().populatefs(results) + self.GetActiveWallpaperWidget().populate(results) + # wallpaper-index + if not updwp and results.has_key('wallpaper-index'): + self.GetActiveWallpaperWidget().updateindex(results) + # ringtone + updrng=False # did we update ringtones + if results['sync'].has_key('ringtone'): + v=results['sync']['ringtone'] + if v=='MERGE': raise Exception("Not implemented") + updrng=True + self.GetActiveRingerWidget().populatefs(results) + self.GetActiveRingerWidget().populate(results) + # ringtone-index + if not updrng and results.has_key('ringtone-index'): + self.GetActiveRingerWidget().updateindex(results) + # calendar + if results['sync'].has_key('calendar'): + v=results['sync']['calendar'] + if v=='MERGE': raise Exception("Not implemented") + results['calendar_version']=self.phoneprofile.BP_Calendar_Version + self.GetActiveCalendarWidget().mergedata(results) +## self.GetActiveCalendarWidget().populatefs(results) +## self.GetActiveCalendarWidget().populate(results) + # memo + if results['sync'].has_key('memo'): + v=results['sync']['memo'] + if v=='MERGE': raise Exception("Not implemented") + self.GetActiveMemoWidget().populatefs(results) + self.GetActiveMemoWidget().populate(results) + # todo + if results['sync'].has_key('todo'): + v=results['sync']['todo'] + if v=='MERGE': raise NotImplementedError + self.GetActiveTodoWidget().populatefs(results) + self.GetActiveTodoWidget().populate(results) + # SMS + if results['sync'].has_key('sms'): + v=results['sync']['sms'] + if v=='MERGE': + self.GetActiveSMSWidget().merge(results) + else: + self.GetActiveSMSWidget().populatefs(results) + self.GetActiveSMSWidget().populate(results) + # call history + if results['sync'].has_key('call_history'): + v=results['sync']['call_history'] + if v=='MERGE': + self.GetActiveCallHistoryWidget().merge(results) + else: + self.GetActiveCallHistoryWidget().populatefs(results) + self.GetActiveCallHistoryWidget().populate(results) + # Playlist + if results['sync'].has_key(playlist.playlist_key): + if results['sync'][playlist.playlist_key]=='MERGE': + raise NotImplementedError + self.GetActivePlaylistWidget().populatefs(results) + self.GetActivePlaylistWidget().populate(results) + # T9 User DB + if results['sync'].has_key(t9editor.dict_key): + if results['sync'][t9editor.dict_key]=='MERGE': + raise NotImplementedError + self.GetActiveT9EditorWidget().populatefs(results) + self.GetActiveT9EditorWidget().populate(results) ### ### Main bit for sending data to the phone ### @@ -1586,10 +1570,8 @@ def OnAutoSyncSettings(self, _=None): if wx.IsBusy(): - with guihelper.WXDialogWrapper(wx.MessageBox("BitPim is busy. You can't change settings until it has finished talking to your phone.", - "BitPim is busy.", wx.OK|wx.ICON_EXCLAMATION), - True): - pass + wx.MessageBox("BitPim is busy. You can't change settings until it has finished talking to your phone.", + "BitPim is busy.", wx.OK|wx.ICON_EXCLAMATION) else: # clear the ower's name for manual setting self.__owner_name='' @@ -1648,7 +1630,9 @@ self.tree.lwdata.log(str) if str.startswith("")+3 - guihelper.MessageDialog(self, str[p:], "Alert", style=wx.OK|wx.ICON_EXCLAMATION) + dlg=wx.MessageDialog(self, str[p:], "Alert", style=wx.OK|wx.ICON_EXCLAMATION) + dlg.ShowModal() + dlg.Destroy() self.OnLog("Alert dialog closed") log=OnLog def OnLogData(self, str, data, klass=None, data_type=None): @@ -1727,9 +1711,9 @@ if text is not None: self.OnLog("Error: "+title+"\n"+text) - with guihelper.WXDialogWrapper(guiwidgets.AlertDialogWithHelp(self,text, title, help, style=style), - True): - pass + dlg=guiwidgets.AlertDialogWithHelp(self,text, title, help, style=style) + dlg.ShowModal() + dlg.Destroy() return True if self.exceptiondialog is None: @@ -1778,9 +1762,9 @@ # Data Recording stuff def OnDataRecording(self, _): - with guihelper.WXDialogWrapper(guiwidgets.DRRecFileDialog(self), - True): - pass + _dlg=guiwidgets.DRRecFileDialog(self) + _dlg.ShowModal() + _dlg.Destroy() # plumbing for the multi-threading @@ -2111,36 +2095,39 @@ keys.sort() op=cStringIO.StringIO() - with contextlib.closing(zipfile.ZipFile(op, "w", zipfile.ZIP_DEFLATED)) as zip: - count=0 - for k in keys: - try: - count+=1 - if files[k]['type']!='file': - continue - self.progressmajor(count, len(keys)+1, "Getting files") - # get the contents - contents=self.getfile(k) - # an artificial sleep. if you get files too quickly, the 4400 eventually - # runs out of buffers and returns truncated packets - time.sleep(0.3) - # add to zip file - zi=zipfile.ZipInfo() - # zipfile does not like unicode. cp437 works on windows well, may be - # a better choice than ascii, but no phones currently support anything - # other than ascii for filenames - if k[strip]=='/': - zi.filename=common.get_ascii_string(k[strip+1:], 'ignore') - else: - zi.filename=common.get_ascii_string(k[strip:], 'ignore') - if files[k]['date'][0]==0: - zi.date_time=(0,0,0,0,0,0) - else: - zi.date_time=time.gmtime(files[k]['date'][0])[:6] - zi.compress_type=zipfile.ZIP_DEFLATED - zip.writestr(zi, contents) - except: - self.log('Failed to read file: '+k) + zip=zipfile.ZipFile(op, "w", zipfile.ZIP_DEFLATED) + + count=0 + for k in keys: + try: + count+=1 + if files[k]['type']!='file': + continue + self.progressmajor(count, len(keys)+1, "Getting files") + # get the contents + contents=self.getfile(k) + # an artificial sleep. if you get files too quickly, the 4400 eventually + # runs out of buffers and returns truncated packets + time.sleep(0.3) + # add to zip file + zi=zipfile.ZipInfo() + # zipfile does not like unicode. cp437 works on windows well, may be + # a better choice than ascii, but no phones currently support anything + # other than ascii for filenames + if k[strip]=='/': + zi.filename=common.get_ascii_string(k[strip+1:], 'ignore') + else: + zi.filename=common.get_ascii_string(k[strip:], 'ignore') + if files[k]['date'][0]==0: + zi.date_time=(0,0,0,0,0,0) + else: + zi.date_time=time.gmtime(files[k]['date'][0])[:6] + zi.compress_type=zipfile.ZIP_DEFLATED + zip.writestr(zi, contents) + except: + self.log('Failed to read file: '+k) + zip.close() + return op.getvalue() def restorefiles(self, files): --- bitpim-1.0.2.dfsg.1.orig/src/sms_tab.py +++ bitpim-1.0.2.dfsg.1/src/sms_tab.py @@ -15,8 +15,6 @@ """ # standard modules -from __future__ import with_statement - import copy # wx modules @@ -320,33 +318,34 @@ current_choice=guiwidgets.HistoricalDataDialog.Historical_Data else: current_choice=guiwidgets.HistoricalDataDialog.Current_Data - with guihelper.WXDialogWrapper(guiwidgets.HistoricalDataDialog(self, - current_choice=current_choice, - historical_date=self.historical_date, - historical_events=\ - self._main_window.database.getchangescount(self._data_key)), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - with guihelper.MWBusyWrapper(self._main_window): - current_choice, self.historical_date=dlg.GetValue() - r={} - if current_choice==guiwidgets.HistoricalDataDialog.Current_Data: - self.read_only=False - msg_str='Current Data' - self.getfromfs(r) - else: - self.read_only=True - msg_str='Historical Data as of %s'%\ - str(wx.DateTimeFromTimeT(self.historical_date)) - self.getfromfs(r, self.historical_date) - self.populate(r, True) - self.historical_data_label.SetLabel(msg_str) - self.list_widget.historical_data_label.SetLabel(msg_str) + dlg=guiwidgets.HistoricalDataDialog(self, + current_choice=current_choice, + historical_date=self.historical_date, + historical_events=\ + self._main_window.database.getchangescount(self._data_key)) + if dlg.ShowModal()==wx.ID_OK: + self._main_window.OnBusyStart() + current_choice, self.historical_date=dlg.GetValue() + r={} + if current_choice==guiwidgets.HistoricalDataDialog.Current_Data: + self.read_only=False + msg_str='Current Data' + self.getfromfs(r) + else: + self.read_only=True + msg_str='Historical Data as of %s'%\ + str(wx.DateTimeFromTimeT(self.historical_date)) + self.getfromfs(r, self.historical_date) + self.populate(r, True) + self.historical_data_label.SetLabel(msg_str) + self.list_widget.historical_data_label.SetLabel(msg_str) + self._main_window.OnBusyEnd() + dlg.Destroy() def OnPrintDialog(self, mainwindow, config): - with guihelper.WXDialogWrapper(guiwidgets.SMSPrintDialog(self, mainwindow, config), - True): - pass + dlg=guiwidgets.SMSPrintDialog(self, mainwindow, config) + dlg.ShowModal() + dlg.Destroy() def CanPrint(self): return True --- bitpim-1.0.2.dfsg.1.orig/src/fileview.py +++ bitpim-1.0.2.dfsg.1/src/fileview.py @@ -13,7 +13,7 @@ ### ### File viewer ### -from __future__ import with_statement + import os import copy import cStringIO @@ -198,17 +198,17 @@ def OnDragOver(self, x, y, d): if self.drag_over: return self.target.OnDragOver(x,y,d) - return wx.FileDropTarget.OnDragOver(self, x, y, d) + return wx.FileDropTarget.base_OnDragOver(self, x, y, d) def OnEnter(self, x, y, d): if self.enter_leave: return self.target.OnEnter(x,y,d) - return wx.FileDropTarget.OnEnter(self, x, y, d) + return wx.FileDropTarget.base_OnEnter(self, x, y, d) def OnLeave(self): if self.enter_leave: return self.target.OnLeave() - return wx.FileDropTarget.OnLeave(self) + return wx.FileDropTarget.base_OnLeave(self) class FileView(wx.Panel, widgets.BitPimWidget): @@ -565,9 +565,8 @@ self.thetimer.Start(1750, wx.TIMER_ONE_SHOT) def OnTooltipTimer(self, _): - if self._in_context_menu or not self.show_thumbnail or \ - wx.GetApp().critical.isSet(): - # we're putting up a context menu or main app is busy, forget this + if self._in_context_menu or not self.show_thumbnail: + # we're putting up a context menu, forget this return # see if we have moved if self.abs_mouse_pos!=wx.GetMousePosition(): @@ -635,24 +634,24 @@ ext=getext(items[0].name) if ext=="": ext="*" else: ext="*."+ext - with guihelper.WXDialogWrapper(wx.FileDialog(self, "Save item", wildcard=ext, defaultFile=items[0].name, style=wx.SAVE|wx.OVERWRITE_PROMPT|wx.CHANGE_DIR), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - file(dlg.GetPath(), "wb").write(self._data[items[0].datakey][items[0].key].mediadata) - if self._data[items[0].datakey][items[0].key].timestamp!=None: - os.utime(dlg.GetPath(), (self._data[items[0].datakey][items[0].key].timestamp, - self._data[items[0].datakey][items[0].key].timestamp)) + dlg=wx.FileDialog(self, "Save item", wildcard=ext, defaultFile=items[0].name, style=wx.SAVE|wx.OVERWRITE_PROMPT|wx.CHANGE_DIR) + if dlg.ShowModal()==wx.ID_OK: + file(dlg.GetPath(), "wb").write(self._data[items[0].datakey][items[0].key].mediadata) + if self._data[items[0].datakey][items[0].key].timestamp!=None: + os.utime(dlg.GetPath(), (self._data[items[0].datakey][items[0].key].timestamp, + self._data[items[0].datakey][items[0].key].timestamp)) + dlg.Destroy() else: - with guihelper.WXDialogWrapper(wx.DirDialog(self, "Save items to", style=wx.DD_DEFAULT_STYLE|wx.DD_NEW_DIR_BUTTON), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - for item in items: - fname=item.name.encode(media_codec) - fname=os.path.join(dlg.GetPath(), basename(fname)) - file(fname, 'wb').write(self._data[item.datakey][item.key].mediadata) - if self._data[item.datakey][item.key].timestamp!=None: - os.utime(fname, (self._data[item.datakey][item.key].timestamp, - self._data[item.datakey][item.key].timestamp)) + dlg=wx.DirDialog(self, "Save items to", style=wx.DD_DEFAULT_STYLE|wx.DD_NEW_DIR_BUTTON) + if dlg.ShowModal()==wx.ID_OK: + for item in items: + fname=item.name.encode(media_codec) + fname=os.path.join(dlg.GetPath(), basename(fname)) + file(fname, 'wb').write(self._data[item.datakey][item.key].mediadata) + if self._data[item.datakey][item.key].timestamp!=None: + os.utime(fname, (self._data[item.datakey][item.key].timestamp, + self._data[item.datakey][item.key].timestamp)) + dlg.Destroy() if guihelper.IsMSWindows(): def OnCopy(self, _): @@ -992,10 +991,10 @@ return True def OnAdd(self, _=None): - with guihelper.WXDialogWrapper(wx.FileDialog(self, "Choose files", style=wx.OPEN|wx.MULTIPLE, wildcard=self.wildcard), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - self.OnAddFiles(dlg.GetPaths()) + dlg=wx.FileDialog(self, "Choose files", style=wx.OPEN|wx.MULTIPLE, wildcard=self.wildcard) + if dlg.ShowModal()==wx.ID_OK: + self.OnAddFiles(dlg.GetPaths()) + dlg.Destroy() def CanRename(self): return len(self.GetSelectedItems())==1 @@ -1007,33 +1006,33 @@ # either none or more than 1 items selected return old_name=items[0].name - with guihelper.WXDialogWrapper(wx.TextEntryDialog(self, "Enter a new name:", "Item Rename", - old_name), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - new_name=dlg.GetValue() - if len(new_name) and new_name!=old_name: - items[0].name=new_name - items[0].RenameInIndex(new_name) - pubsub.publish(pubsub.MEDIA_NAME_CHANGED, - data={ pubsub.media_change_type: self.media_notification_type, - pubsub.media_old_name: old_name, - pubsub.media_new_name: new_name }) + dlg=wx.TextEntryDialog(self, "Enter a new name:", "Item Rename", + old_name) + if dlg.ShowModal()==wx.ID_OK: + new_name=dlg.GetValue() + if len(new_name) and new_name!=old_name: + items[0].name=new_name + items[0].RenameInIndex(new_name) + pubsub.publish(pubsub.MEDIA_NAME_CHANGED, + data={ pubsub.media_change_type: self.media_notification_type, + pubsub.media_old_name: old_name, + pubsub.media_new_name: new_name }) + dlg.Destroy() def OnAddFiles(self,_): - raise NotImplementedError + raise Exception("not implemented") def OnReplace(self, _=None): items=self.GetSelectedItems() if len(items)!=1: # either none or more than 1 items selected return - with guihelper.WXDialogWrapper(wx.FileDialog(self, "Choose file", - style=wx.OPEN, wildcard=self.wildcard), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - self.ReplaceContents(items[0].name, items[0].origin, dlg.GetPath()) - items[0].Refresh() + dlg=wx.FileDialog(self, "Choose file", + style=wx.OPEN, wildcard=self.wildcard) + if dlg.ShowModal()==wx.ID_OK: + self.ReplaceContents(items[0].name, items[0].origin, dlg.GetPath()) + items[0].Refresh() + dlg.Destroy() def get_media_name_from_filename(self, filename, newext=''): path,filename=os.path.split(filename) --- bitpim-1.0.2.dfsg.1.orig/src/calendarcontrol.py +++ bitpim-1.0.2.dfsg.1/src/calendarcontrol.py @@ -374,7 +374,7 @@ def OnLeaveWindow(self, _): self._timer.Stop() def OnTimer(self, _): - if not self.entries or wx.GetApp().critical.isSet(): + if not self.entries: return _rect=self.GetRect() _x,_y=self.GetParent().ClientToScreen(_rect[:2]) --- bitpim-1.0.2.dfsg.1.orig/src/outlook_calendar.py +++ bitpim-1.0.2.dfsg.1/src/outlook_calendar.py @@ -10,7 +10,6 @@ "Deals with Outlook calendar import stuff" # System modules -from __future__ import with_statement import datetime import pywintypes import sys @@ -27,7 +26,6 @@ import bpcalendar import common import common_calendar -import guihelper import guiwidgets import helpids import native.outlook @@ -553,21 +551,23 @@ wx.EVT_BUTTON(self, self.ID_MERGE, self.OnEndModal) wx.EVT_BUTTON(self, wx.ID_HELP, lambda *_: wx.GetApp().displayhelpid(helpids.ID_DLG_CALENDAR_IMPORT)) - @guihelper.BusyWrapper def OnImport(self, evt): - with guihelper.WXDialogWrapper(wx.ProgressDialog(self._progress_dlg_title, - 'Importing Outlook Data, please wait ...\n(Please also watch out for the Outlook Permission Request dialog)', - parent=self)) as dlg: - self._oc.read(None, dlg) - self.populate(self._oc.get_display_data()) - if self._oc.has_errors(): - # display the list of failed items - with guihelper.WXDialogWrapper(wx.SingleChoiceDialog(self, - self._error_dlg_text, - self._error_dlg_title, - self._oc.get_error_list()), - True): - pass + wx.BeginBusyCursor() + dlg=wx.ProgressDialog(self._progress_dlg_title, + 'Importing Outlook Data, please wait ...\n(Please also watch out for the Outlook Permission Request dialog)', + parent=self) + self._oc.read(None, dlg) + self.populate(self._oc.get_display_data()) + dlg.Destroy() + if self._oc.has_errors(): + # display the list of failed items + error_dlg=wx.SingleChoiceDialog(self, + self._error_dlg_text, + self._error_dlg_title, + self._oc.get_error_list()) + error_dlg.ShowModal() + error_dlg.Destroy() + wx.EndBusyCursor() def OnBrowseFolder(self, evt): f=self._oc.pick_folder() @@ -578,11 +578,10 @@ def OnFilter(self, evt): cat_list=self._oc.get_category_list() - with guihelper.WXDialogWrapper(self._filter_dlg_class(self, -1, 'Filtering Parameters', cat_list), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - self._oc.set_filter(dlg.get()) - self.populate(self._oc.get_display_data()) + dlg=self._filter_dlg_class(self, -1, 'Filtering Parameters', cat_list) + if dlg.ShowModal()==wx.ID_OK: + self._oc.set_filter(dlg.get()) + self.populate(self._oc.get_display_data()) def OnEndModal(self, evt): self.EndModal(evt.GetId()) @@ -653,10 +652,10 @@ self._oc.read() self.__read=True cat_list=self._oc.get_category_list() - with guihelper.WXDialogWrapper(common_calendar.AutoSyncFilterDialog(self, -1, 'Filtering Parameters', cat_list)) as dlg: - dlg.set(self._oc.get_filter()) - if dlg.ShowModal()==wx.ID_OK: - self._oc.set_filter(dlg.get()) + dlg=common_calendar.AutoSyncFilterDialog(self, -1, 'Filtering Parameters', cat_list) + dlg.set(self._oc.get_filter()) + if dlg.ShowModal()==wx.ID_OK: + self._oc.set_filter(dlg.get()) def GetFolder(self): return self._oc.get_folder_id() --- bitpim-1.0.2.dfsg.1.orig/src/phonebookentryeditor.py +++ bitpim-1.0.2.dfsg.1/src/phonebookentryeditor.py @@ -7,7 +7,6 @@ ### ### $Id: phonebookentryeditor.py 4412 2007-09-28 01:28:56Z djpham $ -from __future__ import with_statement import wx import fixedscrolledpanel @@ -571,8 +570,8 @@ super(CategoryEditor, self).__del__() def OnManageCategories(self, _): - with guihelper.WXDialogWrapper(CategoryManager(self), True): - pass + dlg=CategoryManager(self) + dlg.ShowModal() def OnUpdateCategories(self, msg): cats=msg.data[:] @@ -1244,7 +1243,7 @@ vs.Fit(self) def Set(self, data): - self._storage.SetValue('SIM' if data.get('sim', False) else 'Phone') + self._storage.SetValue(data.get('sim', False) and 'SIM' or 'Phone') self._secret.SetValue(data.get('secret', False)) def Get(self): @@ -1849,5 +1848,5 @@ } app=wx.PySimpleApp() - with guihelper.WXDialogWrapper(Editor(None,data), True): - pass + dlg=Editor(None,data) + dlg.ShowModal() --- bitpim-1.0.2.dfsg.1.orig/src/native/av/bmp2avi/Makefile +++ bitpim-1.0.2.dfsg.1/src/native/av/bmp2avi/Makefile @@ -14,5 +14,5 @@ SRC=avi_file.cxx bmp_file.cxx b2a.cxx bmp2avi.lbin bmp2avi.mbin bmp2avi.exe: $(SRC) - $(CXX) $(EXTRADEFINES) -O2 -o $@ $(SRC) + $(CXX) $(EXTRADEFINES) $(CXXFLAGS) -o $@ $(SRC) --- bitpim-1.0.2.dfsg.1.orig/src/native/usb/build.sh +++ bitpim-1.0.2.dfsg.1/src/native/usb/build.sh @@ -1,7 +1,8 @@ -PYTHONVER=python2.5 +#!/bin/sh +PYTHONVER=python INCLUDEDIR=`$PYTHONVER -c "import distutils.sysconfig; print distutils.sysconfig.get_python_inc()"` swig -python -I/usr/include libusb.i -gcc -fPIC -Wall -fno-strict-aliasing -O2 -g -shared -I $INCLUDEDIR -o _libusb.so libusb_wrap.c -lusb -strip _libusb.so +gcc -fPIC -Wall -fno-strict-aliasing $CFLAGS -shared -I $INCLUDEDIR -o _libusb.so libusb_wrap.c -lusb +# strip _libusb.so --- bitpim-1.0.2.dfsg.1.orig/src/native/__init__.py +++ bitpim-1.0.2.dfsg.1/src/native/__init__.py @@ -1 +1,3 @@ -# keep python happy +# Handle Debian's split-up layout +__path__.insert(0, '/usr/lib/bitpim/native') + --- bitpim-1.0.2.dfsg.1.orig/src/native/evolution/evolution.py +++ bitpim-1.0.2.dfsg.1/src/native/evolution/evolution.py @@ -38,7 +38,7 @@ import os import re -if sys.platform!="linux2": +if sys.platform!="linux2" and not sys.platform.startswith('gnukfreebsd'): raise ImportError() try: --- bitpim-1.0.2.dfsg.1.orig/src/phones/com_lgvx4650.py +++ bitpim-1.0.2.dfsg.1/src/phones/com_lgvx4650.py @@ -14,8 +14,6 @@ """ # standard modules -from __future__ import with_statement -import contextlib import datetime import time import cStringIO @@ -136,20 +134,25 @@ return result media=result['ringtone'] # get& convert the voice memo files - with contextlib.nested(common.usetempfile('qcp'), - common.usetempfile('wav')) as (_qcp_file, _wav_file): - try: - vmemo_files=self.listfiles(self.VoiceMemoDir) - keys=vmemo_files.keys() - for k in keys: - if k.endswith('.qcp'): - key_name='VoiceMemo'+k[-8:-4] - file(_qcp_file, 'wb').write(self.getfilecontents(k, True)) - conversions.convertqcptowav(_qcp_file, _wav_file) - media[key_name]=file(_wav_file, 'rb').read() - except: - if __debug__: - raise + _qcp_file=common.gettempfilename('qcp') + _wav_file=common.gettempfilename('wav') + try: + vmemo_files=self.listfiles(self.VoiceMemoDir) + keys=vmemo_files.keys() + for k in keys: + if k.endswith('.qcp'): + key_name='VoiceMemo'+k[-8:-4] + file(_qcp_file, 'wb').write(self.getfilecontents(k, True)) + conversions.convertqcptowav(_qcp_file, _wav_file) + media[key_name]=file(_wav_file, 'rb').read() + except: + if __debug__: + raise + try: + os.remove(_qcp_file) + os.remove(_wav_file) + except: + pass result['ringtone']=media return result --- bitpim-1.0.2.dfsg.1.orig/src/phones/com_samsung.py +++ bitpim-1.0.2.dfsg.1/src/phones/com_samsung.py @@ -16,7 +16,7 @@ import time # site-packages -from thirdparty import DSV +from DSV import DSV # BitPim modules import bpcalendar --- bitpim-1.0.2.dfsg.1.orig/src/comscan.py +++ bitpim-1.0.2.dfsg.1/src/comscan.py @@ -49,8 +49,6 @@ L driver string the driver name from /proc/devices (eg ttyS or ttyUSB) """ -from __future__ import with_statement - version="$Revision: 4368 $" import sys @@ -361,14 +359,15 @@ drivers={} # get the list of char drivers from /proc/drivers - with file('/proc/devices', 'r') as f: - f.readline() # skip "Character devices:" header - for line in f.readlines(): - line=line.split() - if len(line)!=2: - break # next section - major,driver=line - drivers[int(major)]=driver + f=open("/proc/devices", "r") + f.readline() # skip "Character devices:" header + for line in f.readlines(): + line=line.split() + if len(line)!=2: + break # next section + major,driver=line + drivers[int(major)]=driver + f.close() # device nodes we have seen so we don't repeat them in listing devcache={} @@ -395,8 +394,9 @@ res['description']=description+" ("+name+")" dev=os.stat(name).st_rdev try: - with file(name, 'rw'): - res['available']=True + f=open(name, "rw") + f.close() + res['available']=True except: res['available']=False # linux specific, and i think they do funky stuff on kernel 2.6 @@ -447,8 +447,9 @@ res['description']="Serial"+" ("+name+")" res['class']="serial" try: - with file(name, 'rw'): - res['available']=True + f=open(name, "rw") + f.close() + res['available']=True except: res['available']=False results[resultscount]=res --- bitpim-1.0.2.dfsg.1.orig/src/bphtml.py +++ bitpim-1.0.2.dfsg.1/src/bphtml.py @@ -8,7 +8,6 @@ ### $Id: bphtml.py 4380 2007-08-29 00:17:07Z djpham $ # Standard modules -from __future__ import with_statement import copy import webbrowser import re @@ -317,26 +316,28 @@ self.parent=parent def PrinterSetup(self): - with guihelper.WXDialogWrapper(wx.PrintDialog(self.parent)) as printerDialog: - if self.printData.Ok(): - printerDialog.GetPrintDialogData().SetPrintData(self.printData.copy()) - printerDialog.GetPrintDialogData().SetSetupDialog(True) - if printerDialog.ShowModal()==wx.ID_OK: - self.printData = PrintData(printerDialog.GetPrintDialogData().GetPrintData()) - self._printdatatoconfig(self.printData) + printerDialog = wx.PrintDialog(self.parent) + if self.printData.Ok(): + printerDialog.GetPrintDialogData().SetPrintData(self.printData.copy()) + printerDialog.GetPrintDialogData().SetSetupDialog(True) + if printerDialog.ShowModal()==wx.ID_OK: + self.printData = PrintData(printerDialog.GetPrintDialogData().GetPrintData()) + self._printdatatoconfig(self.printData) + printerDialog.Destroy() def PageSetup(self): psdd=wx.PageSetupDialogData() if self.printData.Ok(): psdd.SetPrintData(self.printData.copy()) self._configtopagesetupdata(psdd) - with guihelper.WXDialogWrapper(wx.PageSetupDialog(self.parent, psdd)) as pageDialog: - if pageDialog.ShowModal()==wx.ID_OK and \ - pageDialog.GetPageSetupData().Ok() and \ - pageDialog.GetPageSetupData().GetPrintData().Ok(): - self.printData=PrintData(pageDialog.GetPageSetupData().GetPrintData()) - self._printdatatoconfig(self.printData) - self._pagesetupdatatoconfig(pageDialog.GetPageSetupData()) + pageDialog=wx.PageSetupDialog(self.parent, psdd) + if pageDialog.ShowModal()==wx.ID_OK and \ + pageDialog.GetPageSetupData().Ok() and \ + pageDialog.GetPageSetupData().GetPrintData().Ok(): + self.printData=PrintData(pageDialog.GetPageSetupData().GetPrintData()) + self._printdatatoconfig(self.printData) + self._pagesetupdatatoconfig(pageDialog.GetPageSetupData()) + pageDialog.Destroy() def PreviewText(self, htmltext, basepath="", scale=1.0): printout1=self._getprintout(htmltext, basepath, scale) @@ -367,9 +368,9 @@ if not pdd.GetPrintData().Orientation: pdd.GetPrintData().SetOrientation(wx.PORTRAIT) printer=wx.Printer(pdd) - with guihelper.WXDialogWrapper(self._getprintout(htmltext, basepath, scale)) \ - as printout: - printer.Print(self.parent, printout) + printout=self._getprintout(htmltext, basepath, scale) + printer.Print(self.parent, printout) + printout.Destroy() def _getprintout(self, htmltext, basepath, scale): printout=wx.html.HtmlPrintout() @@ -468,7 +469,7 @@ if Renderer._lastsize!=size or Renderer._lastfont!=font: Renderer._hdc.SetFonts(font, "", [int(x*size) for x in _scales]) Renderer._hdc.SetHtmlText(html, basepath) - Renderer._hdc.Render(0, 0, (), 0, False) + Renderer._hdc.Render(0,0,0,False) return (Renderer._mdc.MaxX(), Renderer._mdc.MaxY()) def getbestsize(dc, html, basepath="", font="", size=10): @@ -484,7 +485,7 @@ hdc.SetDC(dc, 1) hdc.SetSize(rect.width, rect.height) hdc.SetHtmlText(html, basepath) - hdc.Render(rect.x, rect.y, (), 0, False) + hdc.Render(rect.x, rect.y, 0, False) dc.SetUserScale(*origscale) --- bitpim-1.0.2.dfsg.1.orig/src/phonebook.py +++ bitpim-1.0.2.dfsg.1/src/phonebook.py @@ -96,7 +96,6 @@ """ # Standard imports -from __future__ import with_statement import os import cStringIO import re @@ -116,7 +115,6 @@ import pubsub import nameparser import bphtml -import guihelper import guiwidgets import phonenumber import helpids @@ -218,10 +216,10 @@ return "%s [%d]" % (phonenumber.format(number['number']), sd) def formatstorage(flag): - return 'SIM' if flag.get('sim', False) else '' + return flag.get('sim', False) and 'SIM' or '' def formatsecret(flag): - return 'True' if flag.get('secret', False) else '' + return flag.get('secret', False) and 'True' or '' # this is specified here as a list so that we can get the # keys in the order below for the settings UI (alpha sorting @@ -785,9 +783,9 @@ return True def OnViewColumnSelector(self): - with guihelper.WXDialogWrapper(ColumnSelectorDialog(self.parent, self.config, self), - True): - pass + dlg=ColumnSelectorDialog(self.parent, self.config, self) + dlg.ShowModal() + dlg.Destroy() def HasPreviewPane(self): return True @@ -818,27 +816,28 @@ current_choice=guiwidgets.HistoricalDataDialog.Historical_Data else: current_choice=guiwidgets.HistoricalDataDialog.Current_Data - with guihelper.WXDialogWrapper(guiwidgets.HistoricalDataDialog(self, - current_choice=current_choice, - historical_date=self.historical_date, - historical_events=\ - self.mainwindow.database.getchangescount('phonebook')), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - with guihelper.MWBusyWrapper(self.mainwindow): - current_choice, self.historical_date=dlg.GetValue() - r={} - if current_choice==guiwidgets.HistoricalDataDialog.Current_Data: - self.read_only=False - msg_str='Current Data' - self.getfromfs(r) - else: - self.read_only=True - msg_str='Historical Data as of %s'%\ - str(wx.DateTimeFromTimeT(self.historical_date)) - self.getfromfs(r, self.historical_date) - self.populate(r, False) - self.historical_data_label.SetLabel(msg_str) + dlg=guiwidgets.HistoricalDataDialog(self, + current_choice=current_choice, + historical_date=self.historical_date, + historical_events=\ + self.mainwindow.database.getchangescount('phonebook')) + if dlg.ShowModal()==wx.ID_OK: + self.mainwindow.OnBusyStart() + current_choice, self.historical_date=dlg.GetValue() + r={} + if current_choice==guiwidgets.HistoricalDataDialog.Current_Data: + self.read_only=False + msg_str='Current Data' + self.getfromfs(r) + else: + self.read_only=True + msg_str='Historical Data as of %s'%\ + str(wx.DateTimeFromTimeT(self.historical_date)) + self.getfromfs(r, self.historical_date) + self.populate(r, False) + self.historical_data_label.SetLabel(msg_str) + self.mainwindow.OnBusyEnd() + dlg.Destroy() def OnIdle(self, _): "We save out changed data" @@ -934,30 +933,29 @@ if datakey in ('categories', 'ringtones', 'wallpapers') and \ len(_keys)>1 and not self.read_only: # Edit a single field for all seleced cells - with guihelper.WXDialogWrapper(phonebookentryeditor.SingleFieldEditor(self, datakey), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - _data=dlg.GetData() - if _data: - for r in _keys: - self._data[r][datakey]=_data - else: - for r in _keys: - del self._data[r][datakey] - self.SetPreview(self._data[_keys[0]]) - self.dt.OnDataUpdated() - self.modified=True + dlg=phonebookentryeditor.SingleFieldEditor(self, datakey) + if dlg.ShowModal()==wx.ID_OK: + _data=dlg.GetData() + if _data: + for r in _keys: + self._data[r][datakey]=_data + else: + for r in _keys: + del self._data[r][datakey] + self.SetPreview(self._data[_keys[0]]) + self.dt.OnDataUpdated() + self.modified=True else: - with guihelper.WXDialogWrapper(phonebookentryeditor.Editor(self, data, - factory=phonebookobjectfactory, - keytoopenon=datakey, - dataindex=dataindex, - readonly=self.read_only, - datakey=key, - movement=True), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - self.SaveData(dlg.GetData(), dlg.GetDataKey()) + dlg=phonebookentryeditor.Editor(self, data, + factory=phonebookobjectfactory, + keytoopenon=datakey, + dataindex=dataindex, + readonly=self.read_only, + datakey=key, + movement=True) + if dlg.ShowModal()==wx.ID_OK: + self.SaveData(dlg.GetData(), dlg.GetDataKey()) + dlg.Destroy() def SaveData(self, data, key): self._data[key]=data @@ -970,18 +968,18 @@ data=self._data[key] # can we get it to open on the correct field? datakey,dataindex=getdatainfo(self.GetColumns()[column], data) - with guihelper.WXDialogWrapper(phonebookentryeditor.Editor(self, data, - factory=phonebookobjectfactory, - keytoopenon=datakey, - dataindex=dataindex, - readonly=self.read_only), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - data=dlg.GetData() - self._data[key]=data - self.dt.OnDataUpdated() - self.SetPreview(data) - self.modified=True + dlg=phonebookentryeditor.Editor(self, data, + factory=phonebookobjectfactory, + keytoopenon=datakey, + dataindex=dataindex, + readonly=self.read_only) + if dlg.ShowModal()==wx.ID_OK: + data=dlg.GetData() + self._data[key]=data + self.dt.OnDataUpdated() + self.SetPreview(data) + self.modified=True + dlg.Destroy() def GetNextEntry(self, next=True): # return the data for the next item on the list @@ -1022,20 +1020,20 @@ def OnAdd(self, _): if self.read_only: return - with guihelper.WXDialogWrapper(phonebookentryeditor.Editor(self, {'names': [{'full': 'New Entry'}]}, keytoopenon="names", dataindex=0), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - data=phonebookobjectfactory.newdataobject(dlg.GetData()) - data.EnsureBitPimSerial() - while True: - key=int(time.time()) - if key in self._data: - continue - break - self._data[key]=data - self.dt.OnDataUpdated() - self.SetPreview(data) - self.modified=True + dlg=phonebookentryeditor.Editor(self, {'names': [{'full': 'New Entry'}]}, keytoopenon="names", dataindex=0) + if dlg.ShowModal()==wx.ID_OK: + data=phonebookobjectfactory.newdataobject(dlg.GetData()) + data.EnsureBitPimSerial() + while True: + key=int(time.time()) + if key in self._data: + continue + break + self._data[key]=data + self.dt.OnDataUpdated() + self.SetPreview(data) + self.modified=True + dlg.Destroy() def GetSelectedRows(self): rows=[] @@ -1083,9 +1081,9 @@ return True def OnPrintDialog(self, mainwindow, config): - with guihelper.WXDialogWrapper(PhonebookPrintDialog(self, mainwindow, config), - True): - pass + dlg=PhonebookPrintDialog(self, mainwindow, config) + dlg.ShowModal() + dlg.Destroy() def getdata(self, dict): dict['phonebook']=self._data.copy() @@ -1220,8 +1218,8 @@ def importdata(self, importdata, categoriesinfo=[], merge=True): if self.read_only: wx.MessageBox('You are viewing historical data which cannot be changed or saved', - 'Cannot Save Phonebook Data', - style=wx.OK|wx.ICON_ERROR) + 'Cannot Save Phonebook Data', + style=wx.OK|wx.ICON_ERROR) return if merge: d=self._data @@ -1229,19 +1227,20 @@ d={} normalise_data(importdata) self._ensure_unicode(importdata) - with guihelper.WXDialogWrapper(ImportDialog(self, d, importdata), - True) as (dlg, retcode): - guiwidgets.save_size("PhoneImportMergeDialog", dlg.GetRect()) - if retcode==wx.ID_OK: - result=dlg.resultdata - if result is not None: - d={} - database.ensurerecordtype(result, phonebookobjectfactory) - database.ensurebitpimserials(result) - d['phonebook']=result - d['categories']=categoriesinfo - self.populatefs(d) - self.populate(d, False) + dlg=ImportDialog(self, d, importdata) + result=None + if dlg.ShowModal()==wx.ID_OK: + result=dlg.resultdata + guiwidgets.save_size("PhoneImportMergeDialog", dlg.GetRect()) + dlg.Destroy() + if result is not None: + d={} + database.ensurerecordtype(result, phonebookobjectfactory) + database.ensurebitpimserials(result) + d['phonebook']=result + d['categories']=categoriesinfo + self.populatefs(d) + self.populate(d, False) def converttophone(self, data): self.error_log.ClearMessages() @@ -1677,7 +1676,6 @@ 'result': _htmlfixup(result), 'colour': colour} - @guihelper.BusyWrapper def OnDataUpdated(self): # update row keys newkeys=self.main.rowdata.keys() @@ -1756,6 +1754,8 @@ self.main.OnCellSelect() self.GetView().Refresh() + OnDataUpdated=guihelper.BusyWrapper(OnDataUpdated) + def _htmlfixup(txt): if txt is None: return "" return txt.replace("&", "&").replace("<", ">").replace(">", "<") \ @@ -1987,7 +1987,6 @@ c.SetValue(True) self.table.OnDataUpdated() - @guihelper.BusyWrapper def DoMerge(self): if len(self.existingdata)*len(self.importdata)>200: progdlg=wx.ProgressDialog("Merging entries", "BitPim is merging the new information into the existing information", @@ -2001,6 +2000,8 @@ progdlg.Destroy() del progdlg + DoMerge=guihelper.BusyWrapper(DoMerge) + def _DoMerge(self, progdlg): """Merges all the importdata with existing data @@ -2253,9 +2254,9 @@ match=len(choices) choices.append( (getdata("Name", self.existingdata[existingkey], ""), existingkey) ) - with guihelper.WXDialogWrapper(ImportedEntryMatchDialog(self, choices, match), - True) as (dlg, retcode): - if retcode==wx.ID_OK: + dlg=ImportedEntryMatchDialog(self, choices, match) + try: + if dlg.ShowModal()==wx.ID_OK: confidence,importkey,existingkey,resultkey=self.table.GetRowData(self.grid.GetGridCursorRow()) assert importkey is not None match=dlg.GetMatch() @@ -2300,6 +2301,8 @@ self.table.OnDataUpdated() return assert False, "Can't get here" + finally: + dlg.Destroy() def OnCellDClick(self, event): self.EditEntry(event.GetRow(), event.GetCol()) @@ -2317,12 +2320,13 @@ else: columnname="Name" datakey, dataindex=getdatainfo(columnname, data) - with guihelper.WXDialogWrapper(phonebookentryeditor.Editor(self, data, keytoopenon=datakey, dataindex=dataindex), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - data=dlg.GetData() - self.resultdata[k]=data - self.table.OnDataUpdated() + dlg=phonebookentryeditor.Editor(self, data, keytoopenon=datakey, dataindex=dataindex) + if dlg.ShowModal()==wx.ID_OK: + data=dlg.GetData() + self.resultdata[k]=data + self.table.OnDataUpdated() + dlg.Destroy() + class ImportedEntryMatchDialog(wx.Dialog): "The dialog shown to select how an imported entry should match" @@ -2868,15 +2872,17 @@ # sort out available layouts and styles # first line is description self.layoutfiles={} - for _file in guihelper.getresourcefiles("pbpl-*.xy"): - with file(_file, 'rt') as f: - desc=f.readline().strip() - self.layoutfiles[desc]=f.read() + for file in guihelper.getresourcefiles("pbpl-*.xy"): + f=open(file, "rt") + desc=f.readline().strip() + self.layoutfiles[desc]=f.read() + f.close() self.stylefiles={} - for _file in guihelper.getresourcefiles("pbps-*.xy"): - with file(_file, 'rt') as f: - desc=f.readline().strip() - self.stylefiles[desc]=f.read() + for file in guihelper.getresourcefiles("pbps-*.xy"): + f=open(file, "rt") + desc=f.readline().strip() + self.stylefiles[desc]=f.read() + f.close() # Layouts vbs=wx.BoxSizer(wx.VERTICAL) # main vertical sizer @@ -2988,7 +2994,6 @@ self.html=self.GetCurrentHTML() self.preview.SetPage(self.html) - @guihelper.BusyWrapper def GetCurrentHTML(self): # Setup a nice environment pointing at this module vars={'phonebook': __import__(__name__) } @@ -3024,11 +3029,14 @@ html=bphtml.applyhtmlstyles(html, sd['styles']) except: if __debug__: - with file("debug.html", "wt") as f: - f.write(html) + f=open("debug.html", "wt") + f.write(html) + f.close() raise return html + GetCurrentHTML=guihelper.BusyWrapper(GetCurrentHTML) + def OnPrintPreview(self, _): wx.GetApp().htmlprinter.PreviewText(self.html, scale=self.scale) @@ -3042,11 +3050,11 @@ wx.GetApp().htmlprinter.PageSetup() def OnSaveHTML(self, _): - with guihelper.WXDialogWrapper(wx.FileDialog(self, wildcard="Web Page (*.htm;*.html)|*.htm;*html", - style=wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT), - True) as (_dlg, _retcode): - if _retcode==wx.ID_OK: - file(_dlg.GetPath(), 'wt').write(self.html) + _dlg=wx.FileDialog(self, wildcard="Web Page (*.htm;*.html)|*.htm;*html", + style=wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) + if _dlg.ShowModal()==wx.ID_OK: + file(_dlg.GetPath(), 'wt').write(self.html) + _dlg.Destroy() def htmlify(string): return common.strorunicode(string).replace("&", "&").replace("<", "<").replace(">", ">").replace("\n", "
") --- bitpim-1.0.2.dfsg.1.orig/src/sms_imexport.py +++ bitpim-1.0.2.dfsg.1/src/sms_imexport.py @@ -9,7 +9,6 @@ "Deals with SMS import/export stuff" # System Module -from __future__ import with_statement from email.Generator import Generator from email.MIMEText import MIMEText from email.Utils import formatdate @@ -19,7 +18,6 @@ # BitPim Modules import bptime -import guihelper import sms #------------------------------------------------------------------------------ @@ -80,12 +78,12 @@ return hbs def OnBrowse(self, _): - with guihelper.WXDialogWrapper(wx.FileDialog(self, defaultFile=self.filenamectrl.GetValue(), - wildcard=self._wildcards[self._format.GetValue()], - style=wx.SAVE|wx.CHANGE_DIR), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - self.filenamectrl.SetValue(dlg.GetPath()) + dlg=wx.FileDialog(self, defaultFile=self.filenamectrl.GetValue(), + wildcard=self._wildcards[self._format.GetValue()], + style=wx.SAVE|wx.CHANGE_DIR) + if dlg.ShowModal()==wx.ID_OK: + self.filenamectrl.SetValue(dlg.GetPath()) + dlg.Destroy() def OnOk(self, _): # do export @@ -95,8 +93,10 @@ except: _fp=None if _fp is None: - guihelper.MessageDialog(self, 'Failed to open file ['+filename+']', - 'Export Error') + dlg=wx.MessageDialog(self, 'Failed to open file ['+filename+']', + 'Export Error') + dlg.ShowModal() + dlg.Destroy() self.EndModal(wx.ID_OK) if self.rows_all.GetValue(): _sms=self._data --- bitpim-1.0.2.dfsg.1.orig/src/bp_config.py +++ bitpim-1.0.2.dfsg.1/src/bp_config.py @@ -68,7 +68,7 @@ def _expand(self, key): # return a tuple of (section, option) based on the key _l=key.split('/') - return ('/'.join(_l[:-1]) if len(_l)>1 else 'DEFAULT', _l[-1]) + return (len(_l)>1 and '/'.join(_l[:-1]) or 'DEFAULT', _l[-1]) def _check_section(self, section): if section and section!='DEFAULT' and not self.has_section(section): --- bitpim-1.0.2.dfsg.1.orig/src/bpcalendar.py +++ bitpim-1.0.2.dfsg.1/src/bpcalendar.py @@ -107,7 +107,6 @@ """ # Standard modules -from __future__ import with_statement import os import copy import calendar @@ -340,8 +339,10 @@ # return the date of the start of the week into which that d falls. _workweek=self.weekstart _dow=d.isoweekday() - return d-datetime.timedelta((_dow-_workweek) if _dow>=_workweek \ - else (_dow+7-_workweek)) + if _dow>=workweek: + return d-datetime.timedelta(_dow-_workweek) + else: + return d-datetime.timedelta(_dow+7-_workweek) def _check_weekly(self, s, d): # check if at least one day-of-week is specified, if not default to the @@ -962,9 +963,9 @@ pubsub.subscribe(self.OnTodayButton, pubsub.MIDNIGHT) def OnPrintDialog(self, mainwindow, config): - with guihelper.WXDialogWrapper(CalendarPrintDialog(self, mainwindow, config), - True): - pass + dlg=CalendarPrintDialog(self, mainwindow, config) + dlg.ShowModal() + dlg.Destroy() def CanPrint(self): return True @@ -1282,11 +1283,11 @@ def mergedata(self, result): """ Merge the newdata (from the phone) into current data """ - with guihelper.WXDialogWrapper(MergeDialog(self, self._data, result.get('calendar', {})), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - self._data=dlg.get() - self.updateonchange() + dlg=MergeDialog(self, self._data, result.get('calendar', {})) + if dlg.ShowModal()==wx.ID_OK: + self._data=dlg.get() + self.updateonchange() + dlg.Destroy() def versionupgrade(self, dict, version): """Upgrade old data format read from disk --- bitpim-1.0.2.dfsg.1.orig/src/update.py +++ bitpim-1.0.2.dfsg.1/src/update.py @@ -8,7 +8,6 @@ ### $Id: update.py 4380 2007-08-29 00:17:07Z djpham $ # system modules -from __future__ import with_statement import copy import urllib2 import xml.dom.minidom @@ -165,9 +164,9 @@ lines.append('\tWarning: '+alert) lines.append('updates.xml Version: '+self.xml_version) lines.append('Latest BitPim Version: '+self.latest_version) - with guihelper.WXDialogWrapper(UpdateDialog(None, dl.source, v.change_log, lines), - True): - pass + dlg=UpdateDialog(None, dl.source, v.change_log, lines) + dlg.ShowModal() + dlg.Destroy() #------------------------------------------------------------------------------- class UpdateDialog(wx.Dialog): @@ -222,19 +221,20 @@ # retrieve and parse update info print 'Checking update for BitPim ', current_version, ' running on ', \ platform, '-', flavor - with guihelper.WXDialogWrapper(wx.ProgressDialog('BitPim Update', - 'Retrieving BitPim Update Information...', - style=wx.PD_AUTO_HIDE)) as dlg: - bp_update=BitPimUpdate() - s=None - try: - if update_url is None: - bp_update.get_update_info() - else: - bp_update.get_update_info(update_url) - dlg.Update(100) - except: - s='Failed to get BitPim update info.' + dlg=wx.ProgressDialog('BitPim Update', + 'Retrieving BitPim Update Information...', + style=wx.PD_AUTO_HIDE) + bp_update=BitPimUpdate() + s=None + try: + if update_url is None: + bp_update.get_update_info() + else: + bp_update.get_update_info(update_url) + dlg.Update(100) + except: + s='Failed to get BitPim update info.' + dlg.Destroy() if s is None: s=bp_update.display_update_info(current_version, platform, flavor) latest_version=bp_update.latest_version @@ -242,7 +242,9 @@ latest_version='' if s is not None: # error messages being return, display them - guihelper.MessageDialog(None, s, 'BitPim Update', wx.OK|wx.ICON_INFORMATION) + dlg=wx.MessageDialog(None, s, 'BitPim Update', wx.OK|wx.ICON_INFORMATION) + dlg.ShowModal() + dlg.Destroy() return latest_version #------------------------------------------------------------------------------- --- bitpim-1.0.2.dfsg.1.orig/src/imp_cal_wizard.py +++ bitpim-1.0.2.dfsg.1/src/imp_cal_wizard.py @@ -13,16 +13,14 @@ """ # System -from __future__ import with_statement + # wx import wx import wx.wizard as wiz import wx.lib.scrolledpanel as scrolled -from wx.lib.expando import ExpandoTextCtrl # BitPim import common_calendar -import guihelper import importexport import setphone_wizard @@ -91,19 +89,27 @@ vbs=wx.BoxSizer(wx.VERTICAL) vbs.Add(wx.StaticText(self, -1, 'Source of data:'), 0, wx.ALL|wx.EXPAND, 5) - self._source_lbl=ExpandoTextCtrl(self, -1, '', style=wx.TE_READONLY) - self._source_lbl.SetBackgroundColour(self.GetBackgroundColour()) - vbs.Add(self._source_lbl, 0, wx.ALL|wx.EXPAND, 5) - + # set the label in a scrolled panel, so the user can scroll to view + # the file name if it's too long. + sp=scrolled.ScrolledPanel(self, -1, size=(-1, 50)) + boxsizer=wx.BoxSizer(wx.VERTICAL) + self._source_lbl=wx.StaticText(sp, -1, '') + boxsizer.Add(self._source_lbl, 1, wx.ALL|wx.EXPAND, 5) + sp.SetSizer(boxsizer) + sp.SetAutoLayout(True) + sp.SetupScrolling(scroll_y=False) + vbs.Add(sp, 0, wx.ALL|wx.EXPAND, 5) + self.sp=sp _btn=wx.Button(self, -1, 'Browse') wx.EVT_BUTTON(self, _btn.GetId(), self._OnBrowse) vbs.Add(_btn, 0, wx.ALL, 5) return vbs def setlabel(self): - self._source_lbl.SetValue(self._source.name()) + self._source_lbl.SetLabel(self._source.name()) + # update the scrolled panel + self.sp.SetVirtualSize(self.sp.GetBestVirtualSize()) - @guihelper.BusyWrapper def _OnBrowse(self, _=None): if not self._source: return @@ -147,26 +153,29 @@ for _key, _entry in self._type.get_display_data().items(): self._data_lb.Append('%s - %s'%(common_calendar.bp_date_str(_entry, _entry['start']), _entry['description'])) - @guihelper.BusyWrapper + def _populate(self): self._data_lb.Clear() if not self._type or not self._source: # nothing to import return - with guihelper.WXDialogWrapper(wx.ProgressDialog('Calendar Data Import', - 'Importing data, please wait ...', - parent=self)) as dlg: - self._type.read(self._source.get(), dlg) - self._populate_lb() + wx.BeginBusyCursor() + dlg=wx.ProgressDialog('Calendar Data Import', + 'Importing data, please wait ...', + parent=self) + self._type.read(self._source.get(), dlg) + dlg.Destroy() + self._populate_lb() + wx.EndBusyCursor() def _OnFilter(self, _): cat_list=self._type.get_category_list() - with guihelper.WXDialogWrapper(common_calendar.FilterDialog(self, -1, 'Filtering Parameters', - cat_list), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - self._type.set_filter(dlg.get()) - self._populate_lb() + dlg=common_calendar.FilterDialog(self, -1, 'Filtering Parameters', + cat_list) + if dlg.ShowModal()==wx.ID_OK: + self._type.set_filter(dlg.get()) + self._populate_lb() + dlg.Destroy() def set(self, data): self._type=data.get('data_obj', None) @@ -200,7 +209,9 @@ ID_ADD=wx.NewId() ID_MERGE=wx.NewId() def __init__(self, parent, id=-1, title='Calendar Import Wizard'): - super(ImportCalendarWizard, self).__init__(parent, id, title) + super(ImportCalendarWizard, self).__init__(parent, id, title, + style=wx.DEFAULT_DIALOG_STYLE|\ + wx.RESIZE_BORDER) self._data={} _import_type_page=ImportTypePage(self) _import_source_page=ImportSourcePage(self) --- bitpim-1.0.2.dfsg.1.orig/src/conversions.py +++ bitpim-1.0.2.dfsg.1/src/conversions.py @@ -9,8 +9,7 @@ ### $Id: conversions.py 4381 2007-08-29 00:19:51Z djpham $ "Routines to do various file format conversions" -from __future__ import with_statement -import contextlib + import os import tempfile import struct @@ -18,17 +17,19 @@ import sys import wx - import common class ConversionFailed(Exception): pass helperdir=os.path.join(common.get_main_dir(), "helpers") -osext={'win32': '.exe', - 'darwin': '.mbin', - 'linux2': '.lbin'} \ - [sys.platform] +if sys.platform.startswith('gnukfreebsd'): + osext='.lbin' +else: + osext={'win32': '.exe', + 'darwin': '.mbin', + 'linux2': '.lbin'} \ + [sys.platform] # This shortname crap is needed because Windows programs (including ffmpeg) # don't correctly parse command line arguments. @@ -79,7 +80,7 @@ path=shell.SHGetFolderPath(0, shellcon.CSIDL_WINDOWS, None, 0) if path: lookin.append(path) - elif sys.platform=='linux2': + elif sys.platform=='linux2' or sys.platform.startswith('gnukfreebsd'): binary="pvconv" lookin.append(_expand("~/bin")) lookin.append(_expand("~")) @@ -134,7 +135,7 @@ osext=".exe" if sys.platform=='darwin': osext=".mbin" - if sys.platform=='linux2': + if sys.platform=='linux2' or sys.platform.startswith('gnukfreebsd'): osext=".lbin" pngtopnmbin=gethelperbinary('pngtopnm') @@ -237,14 +238,18 @@ @param channels: 1 is mono, 2 is stereo """ ffmpeg=gethelperbinary("ffmpeg") - with common.usetempfile('mp3') as mp3file: + mp3file=common.gettempfilename("mp3") + try: try: - run(ffmpeg, "-i", shortfilename(inputfilename), "-hq", "-ab", `bitrate`, "-ar", `samplerate`, "-ac", `channels`, shortfilename(mp3file)) + run(ffmpeg, "-i", shortfilename(inputfilename), "-ab", `bitrate`, "-ar", `samplerate`, "-ac", `channels`, shortfilename(mp3file)) except common.CommandExecutionFailed, e: # we get this exception on bad parameters, or any other # issue so we assume bad parameters for the moment. raise ConversionFailed, ' '.join(e.args)+'\n'+e.logstr - return file(mp3file, "rb").read() + return open(mp3file, "rb").read() + finally: + try: os.remove(mp3file) + except: pass def converttowav(mp3filename, wavfilename, samplerate=None, channels=None, start=None, duration=None): @@ -304,34 +309,39 @@ def adjustwavfilevolume(wavfilename, gain): """ Ajdust the volume of a wav file. """ - with file(wavfilename, 'rb') as f: - # read in the headers - headers=f.read(20) - subchunk1size=common.LSBUint32(headers[16:20]) - headers+=f.read(subchunk1size) - headers+=f.read(8) # 4 byte ID and 4 byte length - subchunk2size=common.LSBUint32(headers[-4:]) - bitspersample=common.LSBUint16(headers[34:36]) - if bitspersample!=16: - print 'Volume adjustment only works with 16-bit wav file',bitspersample - return - sample_num=subchunk2size/2 # always 16-bit per channel per sample - temp_name=common.gettempfilename("wav") - with file(temp_name, 'wb') as f_temp: - f_temp.write(headers) - delta=pow(10.0, (gain/10.0)) - for i in range(sample_num): - d=int(struct.unpack('32767: - d=32767 - elif d<-32768: - d=-32768 - f_temp.write(struct.pack('32767: + d=32767 + elif d<-32768: + d=-32768 + f_temp.write(struct.pack('' sys.exit(1) app=wx.PySimpleApp() - with guihelper.WXDialogWrapper(HexEditorDialog(None, file(sys.argv[1], 'rb').read(), - sys.argv[1]), - True): - pass + dlg=HexEditorDialog(None, file(sys.argv[1], 'rb').read(), + sys.argv[1]) + if True: + dlg.ShowModal() + else: + import hotshot + f=hotshot.Profile("hexeprof",1) + f.runcall(dlg.ShowModal) + f.close() + import hotshot.stats + stats=hotshot.stats.load("hexeprof") + stats.strip_dirs() + # stats.sort_stats("cumulative") + stats.sort_stats("time", "calls") + stats.print_stats(30) + + dlg.Destroy() sys.exit(0) --- bitpim-1.0.2.dfsg.1.orig/src/protogen.py +++ bitpim-1.0.2.dfsg.1/src/protogen.py @@ -9,8 +9,7 @@ ### $Id: protogen.py 4369 2007-08-20 01:59:33Z djpham $ "Generate Python code from packet descriptions" -from __future__ import with_statement -import contextlib + import tokenize import sys import token @@ -684,12 +683,14 @@ print "Processing",inputfilename,"to",outputfilename fn=os.path.basename(outputfilename) fn=os.path.splitext(fn)[0] - with contextlib.nested(file(inputfilename, "rtU"), - file(outputfilename, "wt")) as (f, f2): - tokens=tokenize.generate_tokens(f.readline) - tt=protogentokenizer(tokens, "_gen_"+fn+"_") - cg=codegen(tt) - f2.write(cg.gencode()) + f=open(inputfilename, "rtU") + tokens=tokenize.generate_tokens(f.readline) + tt=protogentokenizer(tokens, "_gen_"+fn+"_") + f2=open(outputfilename, "wt") + cg=codegen(tt) + f2.write(cg.gencode()) + f2.close() + if __name__=='__main__': if len(sys.argv)>3 or (len(sys.argv)==2 and sys.argv[1]=="--help"): --- bitpim-1.0.2.dfsg.1.orig/src/common_calendar.py +++ bitpim-1.0.2.dfsg.1/src/common_calendar.py @@ -10,7 +10,6 @@ "Common stuff for the Calendar Import functions" # system modules -from __future__ import with_statement import calendar import copy import datetime @@ -23,7 +22,6 @@ # local modules import database -import guihelper import guiwidgets import pubsub @@ -98,10 +96,10 @@ def browse(self, parent=None): # how to select a source, default to select a file - with guihelper.WXDialogWrapper(wx.FileDialog(parent, self.message_str, wildcard=self.wildcard), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - self._source=dlg.GetPath() + dlg=wx.FileDialog(parent, self.message_str, wildcard=self.wildcard) + if dlg.ShowModal()==wx.ID_OK: + self._source=dlg.GetPath() + dlg.Destroy() def get(self): # return a source suitable for importing data @@ -766,11 +764,11 @@ return hbs def OnBrowse(self, _): - with guihelper.WXDialogWrapper(wx.FileDialog(self, defaultFile=self.filenamectrl.GetValue(), - wildcard=self._wildcards, style=wx.SAVE|wx.CHANGE_DIR), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - self.filenamectrl.SetValue(dlg.GetPath()) + dlg=wx.FileDialog(self, defaultFile=self.filenamectrl.GetValue(), + wildcard=self._wildcards, style=wx.SAVE|wx.CHANGE_DIR) + if dlg.ShowModal()==wx.ID_OK: + self.filenamectrl.SetValue(dlg.GetPath()) + dlg.Destroy() def _export(self): # perform the actual caledar data import, subclass MUST override --- bitpim-1.0.2.dfsg.1.orig/src/ringers.py +++ bitpim-1.0.2.dfsg.1/src/ringers.py @@ -8,8 +8,6 @@ ### ### $Id: ringers.py 4379 2007-08-28 03:06:58Z djpham $ -from __future__ import with_statement - import os import time import wx @@ -24,7 +22,7 @@ import fileinfo import conversions import helpids -import guihelper + import rangedslider ### @@ -172,16 +170,16 @@ if max_size is not None and len(filedata)>max_size: # the data is too big self.log('ringtone %s is too big!'%common.basename(file)) - with guihelper.WXDialogWrapper(wx.MessageDialog(self, - 'Ringtone %s may be too big. Do you want to proceed anway?'%common.basename(file), - 'Warning', - style=wx.YES_NO|wx.ICON_ERROR), - True) as (dlg, dlg_resp): - if dlg_resp==wx.ID_NO: - return + dlg=wx.MessageDialog(self, + 'Ringtone %s may be too big. Do you want to proceed anway?'%common.basename(file), + 'Warning', + style=wx.YES_NO|wx.ICON_ERROR) + dlg_resp=dlg.ShowModal() + dlg.Destroy() + if dlg_resp==wx.ID_NO: + return self.AddToIndex(name, origin, filedata, self._data, mtime) - - @guihelper.BusyWrapper + def OnAddFiles(self, filenames): for file in filenames: if file is None: continue # failed dragdrop? @@ -213,21 +211,28 @@ if max_size is not None and len(filedata)>max_size: # the data is too big self.log('ringtone %s is too big!'%common.basename(file)) - with guihelper.WXDialogWrapper(wx.MessageDialog(self, - 'Ringtone %s may be too big. Do you want to proceed anway?'%common.basename(file), - 'Warning', - style=wx.YES_NO|wx.ICON_ERROR), - True) as (dlg, dlg_resp): - if dlg_resp==wx.ID_NO: - continue + dlg=wx.MessageDialog(self, + 'Ringtone %s may be too big. Do you want to proceed anway?'%common.basename(file), + 'Warning', + style=wx.YES_NO|wx.ICON_ERROR) + dlg_resp=dlg.ShowModal() + dlg.Destroy() + if dlg_resp==wx.ID_NO: + continue target=self.get_media_name_from_filename(file, newext) self.AddToIndex(target, self.active_section, filedata, self._data, mtime) self.OnRefresh() + OnAddFiles=guihelper.BusyWrapper(OnAddFiles) + def ConvertFormat(self, file, convertinfo): - with guihelper.WXDialogWrapper(ConvertDialog(self, file, convertinfo), - True) as (dlg, retcode): - return dlg.newfiledata if retcode==wx.ID_OK else None + dlg=ConvertDialog(self, file, convertinfo) + if dlg.ShowModal()==wx.ID_OK: + res=dlg.newfiledata + else: + res=None + dlg.Destroy() + return res def versionupgrade(self, dict, version): """Upgrade old data format read from disk @@ -442,7 +447,7 @@ self.clip_duration.GetId(), self.clip_volume.GetId(), clip_set_btn.GetId()] - @guihelper.BusyWrapper + def OnConvert(self, _): self.OnStop() for i in self.cropids: @@ -458,6 +463,9 @@ self.FindWindowById(i).Enable(True) self.FindWindowById(wx.ID_OK).Enable(True) + OnConvert=guihelper.BusyWrapper(OnConvert) + + def UpdateCrop(self): self.positionlabel.SetLabel("%.1f secs" % (self.slider.GetCurrent()*self.wfi.duration),) duration=(self.slider.GetEnd()-self.slider.GetStart())*self.wfi.duration @@ -532,8 +540,7 @@ for file in self.temporaryfiles: if os.path.exists(file): os.remove(file) - - @guihelper.BusyWrapper + def OnOk(self, evt): self.OnStop() # make new data @@ -588,12 +595,17 @@ def _trim_mp3(self, start, duration): # mp3 writing out - frames=self.afi.frames - offset=frames[self.beginframe].offset - length=frames[self.endframe-1].nextoffset-offset - with file(self.mp3file, 'rb', 0) as f: + f=None + try: + frames=self.afi.frames + offset=frames[self.beginframe].offset + length=frames[self.endframe-1].nextoffset-offset + f=open(self.mp3file, "rb", 0) f.seek(offset) return f.read(length) + finally: + if f is not None: + f.close() def _trim_and_adjust_vol_mp3(self, start, duration, volume): # trim, adjust volume, and write mp3 out @@ -648,4 +660,4 @@ conversions.adjustwavfilevolume(self.wavfile, volume) conversions.convertwavtoqcp(self.wavfile, self.qcpfile, self.optimization.GetSelection()) - return file(self.qcpfile, "rb").read() + return open(self.qcpfile, "rb").read() --- bitpim-1.0.2.dfsg.1.orig/src/wallpaper.py +++ bitpim-1.0.2.dfsg.1/src/wallpaper.py @@ -10,7 +10,6 @@ "Deals with wallpaper and related views" # standard modules -from __future__ import with_statement import os import sys import cStringIO @@ -283,8 +282,9 @@ else: img=wx.Image(file) if not img.Ok(): - guihelper.MessageDialog(self, "Failed to understand the image in '"+file+"'", - "Image not understood", style=wx.OK|wx.ICON_ERROR) + dlg=wx.MessageDialog(self, "Failed to understand the image in '"+file+"'", + "Image not understood", style=wx.OK|wx.ICON_ERROR) + dlg.ShowModal() continue self.OnAddImage(img,file,refresh=False, timestamp=mtime) self.OnRefresh() @@ -299,75 +299,106 @@ else: img=wx.Image(new_file_name) if not img.Ok(): - guihelper.MessageDialog(self, "Failed to understand the image in '"+new_file_name+"'", - "Image not understood", style=wx.OK|wx.ICON_ERROR) + dlg=wx.MessageDialog(self, "Failed to understand the image in '"+new_file_name+"'", + "Image not understood", style=wx.OK|wx.ICON_ERROR) + dlg.ShowModal() + dlg.Destroy() return - with guihelper.WXDialogWrapper(ImagePreviewDialog(self, img, self.mainwindow.phoneprofile, self.active_section), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - img=dlg.GetResultImage() - imgparams=dlg.GetResultParams() - # ::TODO:: temporary hack - this should really be an imgparam - extension={'BMP': 'bmp', 'JPEG': 'jpg', 'PNG': 'png'}[imgparams['format']] - - res=getattr(self, "saveimage_"+imgparams['format'])(img, imgparams) - if not res: - guihelper.MessageDialog(self, "Failed to convert the image in '"+new_file_name+"'", - "Image not converted", style=wx.OK|wx.ICON_ERROR) - self.AddToIndex(name, origin, res, self._data) + dlg=ImagePreviewDialog(self, img, self.mainwindow.phoneprofile, self.active_section) + if dlg.ShowModal()!=wx.ID_OK: + dlg.Destroy() + return + + img=dlg.GetResultImage() + imgparams=dlg.GetResultParams() + dlg.Destroy() + # ::TODO:: temporary hack - this should really be an imgparam + extension={'BMP': 'bmp', 'JPEG': 'jpg', 'PNG': 'png'}[imgparams['format']] + + res=getattr(self, "saveimage_"+imgparams['format'])(img, imgparams) + if not res: + dlg=wx.MessageDialog(self, "Failed to convert the image in '"+new_file_name+"'", + "Image not converted", style=wx.OK|wx.ICON_ERROR) + dlg.ShowModal() + dlg.Destroy() + self.AddToIndex(name, origin, res, self._data) def OnAddImage(self, img, file, refresh=True, timestamp=None): # ::TODO:: if file is None, find next basename in our directory for # clipboard99 where 99 is next unused number - with guihelper.WXDialogWrapper(ImagePreviewDialog(self, img, self.mainwindow.phoneprofile, self.active_section), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - img=dlg.GetResultImage() - imgparams=dlg.GetResultParams() - origin=self.active_section - # if we modified the image update the timestamp - if not dlg.skip: - timestamp=int(time.time()) - - # ::TODO:: temporary hack - this should really be an imgparam - extension={'BMP': 'bmp', 'JPEG': 'jpg', 'PNG': 'png'}[imgparams['format']] - - # munge name - targetfilename=self.get_media_name_from_filename(file, extension) - - res=getattr(self, "saveimage_"+imgparams['format'])(img, imgparams) - if not res: - guihelper.MessageDialog(self, "Failed to convert the image in '"+file+"'", - "Image not converted", style=wx.OK|wx.ICON_ERROR) - return - - self.AddToIndex(targetfilename, origin, res, self._data, timestamp) - if refresh: - self.OnRefresh() + dlg=ImagePreviewDialog(self, img, self.mainwindow.phoneprofile, self.active_section) + if dlg.ShowModal()!=wx.ID_OK: + dlg.Destroy() + return + + img=dlg.GetResultImage() + imgparams=dlg.GetResultParams() + origin=self.active_section + # if we modified the image update the timestamp + if not dlg.skip: + timestamp=int(time.time()) + + # ::TODO:: temporary hack - this should really be an imgparam + extension={'BMP': 'bmp', 'JPEG': 'jpg', 'PNG': 'png'}[imgparams['format']] + + # munge name + targetfilename=self.get_media_name_from_filename(file, extension) + + res=getattr(self, "saveimage_"+imgparams['format'])(img, imgparams) + if not res: + dlg=wx.MessageDialog(self, "Failed to convert the image in '"+file+"'", + "Image not converted", style=wx.OK|wx.ICON_ERROR) + dlg.ShowModal() + return + + self.AddToIndex(targetfilename, origin, res, self._data, timestamp) + if refresh: + self.OnRefresh() def saveimage_BMP(self, img, imgparams): if img.ComputeHistogram(wx.ImageHistogram())<=236: # quantize only does 236 or less img.SetOptionInt(wx.IMAGE_OPTION_BMP_FORMAT, wx.BMP_8BPP) - with common.usetempfile('bmp') as f: - if img.SaveFile(f, wx.BITMAP_TYPE_BMP): - return file(f, 'rb').read() + f=common.gettempfilename("bmp") + rc = img.SaveFile(f, wx.BITMAP_TYPE_BMP) + if rc: + data = open(f, 'rb').read() + try: + os.remove(f) + except: + pass + if not rc: return False + return data def saveimage_JPEG(self, img, imgparams): img.SetOptionInt("quality", 100) - with common.usetempfile('jpg') as f: - if img.SaveFile(f, wx.BITMAP_TYPE_JPEG): - return file(f, 'rb').read() + f=common.gettempfilename("jpg") + rc = img.SaveFile(f, wx.BITMAP_TYPE_JPEG) + if rc: + data = open(f, 'rb').read() + try: + os.remove(f) + except: + pass + if not rc: return False + return data def saveimage_PNG(self, img, imgparams): # ::TODO:: this is where the file size constraints should be examined # and obeyed - with common.usetempfile('png') as f: - if img.SaveFile(f, wx.BITMAP_TYPE_PNG): - return file(f, 'rb').read() + f=common.gettempfilename("png") + rc = img.SaveFile(f, wx.BITMAP_TYPE_PNG) + if rc: + data = open(f, 'rb').read() + try: + os.remove(f) + except: + pass + if not rc: return False + return data def versionupgrade(self, dict, version): """Upgrade old data format read from disk @@ -617,11 +648,14 @@ else: b=img.ConvertToBitmap() - with common.usetempfile('png') as f: - if not b.SaveFile(f, wx.BITMAP_TYPE_PNG): - raise Exception, "Saving to png failed" - data=open(f, "rb").read() - return (cStringIO.StringIO(data), location, "image/png", "", wx.DateTime_Now()) + f=common.gettempfilename("png") + if not b.SaveFile(f, wx.BITMAP_TYPE_PNG): + raise Exception, "Saving to png failed" + + data=open(f, "rb").read() + os.remove(f) + + return (cStringIO.StringIO(data), location, "image/png", "", wx.DateTime_Now()) class ImageCropSelect(wx.ScrolledWindow): --- bitpim-1.0.2.dfsg.1.orig/src/ical_calendar.py +++ bitpim-1.0.2.dfsg.1/src/ical_calendar.py @@ -10,7 +10,6 @@ "Deals with iCalendar calendar import stuff" # system modules -from __future__ import with_statement import datetime import time @@ -20,7 +19,6 @@ import bpcalendar import bptime import common_calendar -import guihelper import vcal_calendar as vcal import vcard @@ -479,8 +477,10 @@ except: f=None if f is None: - guihelper.MessageDialog(self, 'Failed to open file ['+filename+']', - 'Export Error') + dlg=wx.MessageDialog(self, 'Failed to open file ['+filename+']', + 'Export Error') + dlg.ShowModal() + dlg.Destroy() return all_items=self._selection.GetSelection()==0 dt=self._start_date.GetValue() --- bitpim-1.0.2.dfsg.1.orig/src/call_history_export.py +++ bitpim-1.0.2.dfsg.1/src/call_history_export.py @@ -9,13 +9,12 @@ "Deals with Call History import/export stuff" # System Module -from __future__ import with_statement + # wxPython modules import wx # BitPim Modules import bptime -import guihelper import phonenumber #------------------------------------------------------------------------------ @@ -64,11 +63,11 @@ return hbs def OnBrowse(self, _): - with guihelper.WXDialogWrapper(wx.FileDialog(self, defaultFile=self.filenamectrl.GetValue(), - wildcard="CSV files (*.csv)|*.csv", style=wx.SAVE|wx.CHANGE_DIR), - True) as (dlg, retcode): - if retcode==wx.ID_OK: - self.filenamectrl.SetValue(dlg.GetPath()) + dlg=wx.FileDialog(self, defaultFile=self.filenamectrl.GetValue(), + wildcard="CSV files (*.csv)|*.csv", style=wx.SAVE|wx.CHANGE_DIR) + if dlg.ShowModal()==wx.ID_OK: + self.filenamectrl.SetValue(dlg.GetPath()) + dlg.Destroy() def OnOk(self, _): # do export @@ -78,8 +77,10 @@ except: _fp=None if _fp is None: - guihelper.MessageDialog(self, 'Failed to open file ['+filename+']', - 'Export Error') + dlg=wx.MessageDialog(self, 'Failed to open file ['+filename+']', + 'Export Error') + dlg.ShowModal() + dlg.Destroy() self.EndModal(wx.ID_OK) if self.rows_all.GetValue(): _data=self._data --- bitpim-1.0.2.dfsg.1.orig/debian/bitpim.dirs +++ bitpim-1.0.2.dfsg.1/debian/bitpim.dirs @@ -0,0 +1 @@ +usr/share/bitpim/helpers --- bitpim-1.0.2.dfsg.1.orig/debian/bitpim.menu +++ bitpim-1.0.2.dfsg.1/debian/bitpim.menu @@ -0,0 +1,13 @@ +?package(bitpim): \ + needs="x11" \ + section="Applications/Mobile Devices" \ + title="BitFling" \ + command="/usr/bin/bitfling" \ + icon="/usr/share/pixmaps/bitfling.xpm" + +?package(bitpim): \ + needs="x11" \ + section="Applications/Mobile Devices" \ + title="BitPim" \ + command="/usr/bin/bitpim" \ + icon="/usr/share/pixmaps/bitpim.xpm" --- bitpim-1.0.2.dfsg.1.orig/debian/bitpim-lib.postinst +++ bitpim-1.0.2.dfsg.1/debian/bitpim-lib.postinst @@ -0,0 +1,24 @@ +#!/bin/sh +set -e + +#DEBHELPER# + +# Standard tools just arrange to produce unoptimized .pyc files; ensure +# that we also have optimized .pyo files for better performance. +# (Compile with -Wignore per #358023, and cover /usr/share/bitpim/code +# in addition to /usr/lib/bitpim to ensure that bitpim's .pyo files +# will remain valid when the default Python version changes.) + +if test -x /usr/bin/pyversions; then + PYTHON=`pyversions -d` +else + PYTHON=python2.3 +fi + +if which $PYTHON >/dev/null 2>&1 && [ -e /usr/lib/$PYTHON/compileall.py ]; then + for d in /usr/lib/bitpim /usr/share/bitpim/code; do + test -d $d && $PYTHON -OO -Wignore /usr/lib/$PYTHON/compileall.py -q $d + done +fi + +exit 0 --- bitpim-1.0.2.dfsg.1.orig/debian/control +++ bitpim-1.0.2.dfsg.1/debian/control @@ -0,0 +1,33 @@ +Source: bitpim +Section: comm +Priority: extra +Maintainer: Aaron M. Ucko +Build-Depends: cdbs, debhelper (>= 5.0.47), lynx, python (>= 2.4), python-dev (>= 2.4), python-support (>= 0.4.2), libusb-dev, swig, unzip +Build-Depends-Indep: imagemagick +Standards-Version: 3.7.2 +Homepage: http://www.bitpim.org/ + +Package: bitpim +Architecture: all +Depends: ${python:Depends}, bitpim-lib, python-apsw (>= 3.3.13-r1), python-crypto, python-ctypes, python-dsv, python-paramiko, python-serial, python-wxgtk2.6 (>= 2.6.2) +Recommends: netpbm +Suggests: ffmpeg, udev +Provides: bitfling +Replaces: bitfling +Conflicts: bitfling +Description: utility to communicate with many CDMA phones + BitPim allows you to view and manipulate data on many phones from LG, + Samsung, Sanyo, and other manufacturers that use Qualcomm CDMA chips. + Depending on your phone model, you may be able to access the phone + book, the calendar, wallpapers, ring tones, and the filesystem. + +Package: bitpim-lib +Architecture: any +Depends: ${python:Depends}, ${shlibs:Depends} +Description: architecture-dependent helper files for BitPim + BitPim allows you to view and manipulate data on many phones from LG, + Samsung, Sanyo, and other manufacturers that use Qualcomm CDMA chips. + Depending on your phone model, you may be able to access the phone + book, the calendar, wallpapers, ring tones, and the filesystem. + . + This package contains a handful of architecture-dependent helper files. --- bitpim-1.0.2.dfsg.1.orig/debian/bitpim.links +++ bitpim-1.0.2.dfsg.1/debian/bitpim.links @@ -0,0 +1,6 @@ +usr/lib/bitpim/bmp2avi.lbin usr/share/bitpim/helpers/bmp2avi.lbin +usr/bin/ffmpeg usr/share/bitpim/helpers/ffmpeg.lbin +usr/bin/pngtopnm usr/share/bitpim/helpers/pngtopnm.lbin +usr/bin/pnmtopng usr/share/bitpim/helpers/pnmtopng.lbin +usr/bin/ppmquant usr/share/bitpim/helpers/ppmquant.lbin +usr/share/python-support/python-dsv/DSV usr/share/bitpim/code/DSV --- bitpim-1.0.2.dfsg.1.orig/debian/bitpim.prerm +++ bitpim-1.0.2.dfsg.1/debian/bitpim.prerm @@ -0,0 +1,9 @@ +#!/bin/sh +set -e + +#DEBHELPER# + +dpkg -L bitpim | + awk '$0~/\.py$/ {print $0"c\n" $0"o"}' | + xargs rm -f >&2 +exit 0 --- bitpim-1.0.2.dfsg.1.orig/debian/bitpim.sh +++ bitpim-1.0.2.dfsg.1/debian/bitpim.sh @@ -0,0 +1,2 @@ +#!/bin/sh +exec /usr/bin/python -OO /usr/share/bitpim/code/bp.py "$@" --- bitpim-1.0.2.dfsg.1.orig/debian/bitpim.1 +++ bitpim-1.0.2.dfsg.1/debian/bitpim.1 @@ -0,0 +1,35 @@ +.TH BITPIM 1 "2006-02-04" +.SH NAME +bitpim \- utility to communicate with many CDMA phones +.SH SYNOPSIS +.B bitpim +[ \fB-c\fP\ \fIfile\fP | \fB-d\fP\ \fIdir\fP ] +.SH DESCRIPTION +This manual page documents briefly the +.B bitpim +command. +.PP +BitPim allows you to view and manipulate data on many phones from LG, +Samsung, Sanyo, and other manufacturers that use Qualcomm CDMA chips. +Depending on your phone model, you may be able to access the phone +book, the calendar, wallpapers, ring tones, and the filesystem. +.SH OPTIONS +A summary of options is included below. +.TP +\fB-c\fP\ \fIfile\fP +Read configuration from \fIfile\fP. +.TP +\fB-d\fP\ \fIdir\fP +Read configuration from \fIdir\fP\fB/.bitpim\fP. +.SH FILES +.TP +\fB$HOME/.bitpim-files/.bitpim\fP +The default configuration file. +.SH SEE ALSO +.BR bitfling (1), +http://www.bitpim.org/. +.SH AUTHOR +\fBbitpim\fP was primarily written by Roger Binns . +.PP +This manual page was written by Aaron M. Ucko , +for the Debian project (but may be used by others). --- bitpim-1.0.2.dfsg.1.orig/debian/rules +++ bitpim-1.0.2.dfsg.1/debian/rules @@ -0,0 +1,113 @@ +#!/usr/bin/make -f +include /usr/share/cdbs/1/rules/debhelper.mk +include /usr/share/cdbs/1/class/langcore.mk +# include /usr/share/cdbs/1/class/python-distutils.mk + +DEB_DH_INSTALL_SOURCEDIR = debian/tmp +DEB_INSTALL_CHANGELOGS_ALL = debian/changelog.upstream + +datadir = /usr/share/bitpim +libdir = /usr/lib/bitpim + +data_dest = $(DEB_DESTDIR)$(datadir) +lib_dest = $(DEB_DESTDIR)$(libdir) +code_dest = $(data_dest)/code +res_dest = $(data_dest)/resources +dtop_dest = $(DEB_DESTDIR)/usr/share/applications +udev_bin = $(DEB_DESTDIR)/lib/udev +conf_dest = $(DEB_DESTDIR)/etc/default +icon_dest = $(DEB_DESTDIR)/usr/share/pixmaps + +export CFLAGS CXXFLAGS + +clean:: +# $(MAKE) -C src/native/av/bmp2avi clean PLATFORM=linux + rm -f src/native/av/bmp2avi/bmp2avi.lbin helpers/bmp2avi.lbin + cd src/native/strings && python setup.py clean -a && \ + rm -rf build *.so *.pyc + cd src/native/usb && rm -f libusb_wrap.c libusb.py _libusb.so + chmod -x examples/* + rm -f debian/changelog.upstream debian/stamp-built + rm -f resources/60-bitpim.rules debian/bitpim.udev src/*.pyc src/*/*.pyc + +common-build-arch:: debian/stamp-built + +debian/stamp-built: + mkdir -p helpers +# $(MAKE) -C src/native/av/bmp2avi PLATFORM=linux CXXFLAGS="$(CXXFLAGS)" +# cd src/native/strings && python setup.py build --build-base="./build" +# cd src/native/usb && sh -x ./build.sh + python packaging/buildmodules.py all + touch $@ + +debian/changelog.upstream: + unzip -p resources/bitpim.htb versionhistory.htm \ + | lynx -dump -stdin -nolist > $@ + +debian/bitpim.udev: resources/60-bitpim.rules + sort $< | sed -e 's:/usr/bin:/lib/udev:p' \ + -e 's:"add":"remove":; s:/bpudev :&--del :' > $@ + +resources/60-bitpim.rules: + PYTHONPATH=src python -c 'import package; package.generate_udevrules()' + +common-install-arch:: debian/changelog.upstream + mkdir -p $(lib_dest)/native/usb + cp src/native/av/bmp2avi/bmp2avi.lbin $(lib_dest) + cd src/native/strings && \ + python setup.py install --root=$(DEB_DESTDIR) --no-compile -O0 \ + --install-lib=$(libdir)/native/strings + install -m644 src/native/strings/__init__.py $(lib_dest)/native/strings + cp src/native/usb/*.py src/native/usb/*.so $(lib_dest)/native/usb + +common-install-indep:: debian/changelog.upstream debian/bitpim.udev + mkdir -p $(DEB_DESTDIR)/usr/bin + install -m755 debian/bitfling.sh $(DEB_DESTDIR)/usr/bin/bitfling + install -m755 debian/bitpim.sh $(DEB_DESTDIR)/usr/bin/bitpim + mkdir -p $(code_dest) + install -m644 src/*.py $(code_dest) + sed -e 's/^\(vendor=\)".*"/\1"Debian"/' src/version.py \ + > $(code_dest)/version.py + cd $(code_dest) && chmod +x analyser.py bp.py \ + brewcompressedimage.py calendarcontrol.py comdiagnose.py \ + comscan.py hexeditor.py setphone_wizard.py usb_ids.py version.py + mkdir $(code_dest)/native + install -m644 src/native/*.py $(code_dest)/native + install -m644 src/native/strings/jarowpy.py \ + $(code_dest)/native/strings.py + for x in egroupware evolution qtopiadesktop; do \ + mkdir -p $(code_dest)/native/$$x && \ + install -m644 src/native/$$x/*.py $(code_dest)/native/$$x; \ + done + mkdir $(code_dest)/phones + install -m644 src/phones/*.py $(code_dest)/phones + mkdir $(res_dest) + install -m644 resources/* $(res_dest) + rm -f $(res_dest)/bitpim.chm + mkdir $(code_dest)/bitfling + install -m644 src/bitfling/*.py $(code_dest)/bitfling + chmod +x $(code_dest)/bitfling/xmlrpcstuff.py + mkdir -p $(dtop_dest) + sed -e 's,%%INSTALLBINDIR%%,/usr/bin,g' \ + -e 's,%%INSTALLLIBDIR%%,$(datadir),g' \ + -e 's,^\(Categories=\)Application;\(.*\);\(Utility\),\1\3;\2,' \ + -e 's,^\(Terminal=\)0,\1false,' \ + packaging/bitpim.desktop > $(dtop_dest)/bitpim.desktop + mkdir -p $(udev_bin) + install -m755 resources/bpudev $(udev_bin) + mkdir -p $(conf_dest) + install -m644 debian/bitpim.default $(conf_dest)/bitpim + mkdir -p $(icon_dest) + convert resources/bitfling.png $(icon_dest)/bitfling.xpm + convert resources/bitpim.ico $(icon_dest)/bitpim.xpm + +# binary-install/bitfling:: +# dh_python -pbitfling /usr/share/bitpim/code/bitfling + +binary-install/bitpim:: + dh_pysupport -pbitpim +# dh_python -pbitpim + +binary-install/bitpim-lib:: + dh_pysupport -pbitpim-lib /usr/lib/bitpim +# dh_python -pbitpim-lib /usr/lib/bitpim --- bitpim-1.0.2.dfsg.1.orig/debian/watch +++ bitpim-1.0.2.dfsg.1/debian/watch @@ -0,0 +1,8 @@ +# See uscan(1) for format +version=3 +# Upstream doesn't actually distribute tarballs, so we have to use +# binary packages as proxies and pull sources from Subversion. +opts=dversionmangle=s/\.dfsg\.\d+$// \ + http://sf.net/bitpim/bitpim-(\d+\.\d+\.\d+)-0\.i386\.rpm + + --- bitpim-1.0.2.dfsg.1.orig/debian/changelog +++ bitpim-1.0.2.dfsg.1/debian/changelog @@ -0,0 +1,282 @@ +bitpim (1.0.2.dfsg.1-2) unstable; urgency=low + + * Revive (reworked) udev rules, and document how to ensure suitable + device ownership and permissions. (Closes: #450550.) + * Correct watch file to ignore prerelease snapshots. + * Note upstream's homepage in debian/control. + * Clarify (L)GPL versioning (no upper bounds) in debian/copyright. + + -- Aaron M. Ucko Sun, 11 Nov 2007 21:31:05 -0500 + +bitpim (1.0.2.dfsg.1-1) unstable; urgency=low + + * New upstream release. + * Revert upstream changes that require Python 2.5, but keep those that + merely require 2.4, bumping (build) dependencies accordingly. + * Fix bitpim.desktop to satisfy desktop-file-validate; in particular, + don't lose Category= when adjusting its value! (Closes: #443519.) + + -- Aaron M. Ucko Thu, 11 Oct 2007 19:33:36 -0400 + +bitpim (1.0.1.dfsg.1-1) unstable; urgency=low + + * New upstream release. + * Fix bitpim.desktop to cite Utility rather than Application as its main + category. + * debian/menu: Apps/Tools -> Applications/Mobile Devices per new policy; + belatedly add icons (converted from upstream's). + + -- Aaron M. Ucko Fri, 10 Aug 2007 19:00:11 -0400 + +bitpim (1.0.0.dfsg.1-1) unstable; urgency=medium + + * Official 1.0 release (with only minor changes from 0.9.15). + + -- Aaron M. Ucko Wed, 13 Jun 2007 19:49:39 -0400 + +bitpim (0.9.15.dfsg.1-1) unstable; urgency=low + + * New upstream release. + + -- Aaron M. Ucko Wed, 23 May 2007 18:35:49 -0400 + +bitpim (0.9.14.dfsg.1-2) unstable; urgency=low + + * Depend on apsw 3.3.13-r1, and restore the new database code that + upstream introduced in 0.9.12. + * Build-Depend on debhelper 5.0.47 for direct udev rules.d installation + (though the rules themselves remain commented out). + + -- Aaron M. Ucko Tue, 17 Apr 2007 17:49:41 -0400 + +bitpim (0.9.14.dfsg.1-1) unstable; urgency=low + + * The "spring holiday of your choice" release. + * New upstream release. + * src/{bphtml,fileview,gui,guiwidgets,imp_cal_wizard,newdb_wiz}.py: + revert wx2.8-isms for the time being, as Debian still only has 2.6. + + -- Aaron M. Ucko Sun, 8 Apr 2007 18:25:57 -0400 + +bitpim (0.9.13.dfsg.1-1) unstable; urgency=low + + * New upstream release. + * packaging/buildmodules.py, src/native/evolution/evolution.py, + src/conversions.py: treat GNU/kFreeBSD (sys.platform gnukfreebsd*) + equivalently to Linux (sys.platform linux2). (Closes: #414274.) + * src/{memo,todo}.py (*Widget._OnSave): make sure to enable the item + list before attempting to query its selection. (Closes: #413113.) + + -- Aaron M. Ucko Tue, 20 Mar 2007 19:50:24 -0400 + +bitpim (0.9.12.dfsg.1-1) unstable; urgency=low + + * New upstream release (skipping 0.9.11). + * src/{database,fileview,phone_root}.py: revert use of SQLite virtual + tables, as they require a newer version of apsw than Debian ships at + present (or is likely to until etch releases). + * src/native/usb/libusb.i: add more typedefs for compatibility with + libusb 2:0.1.12-4, as SWIG doesn't automatically recognize the new + names either. (Bug #315165 documents the change.) + * src/{importexport,phones/com_samsung}.py: Continue using Debian's + DSV.py (from my python-dsv package) rather than a (new) private copy. + + -- Aaron M. Ucko Tue, 27 Feb 2007 19:45:52 -0500 + +bitpim (0.9.10.dfsg.1-1) unstable; urgency=low + + * New upstream release. + + -- Aaron M. Ucko Thu, 28 Dec 2006 16:14:51 -0500 + +bitpim (0.9.09.dfsg.1-1) unstable; urgency=medium + + * New upstream release; urgency medium because it fixes some more bugs + and seems pretty stable. + + -- Aaron M. Ucko Thu, 7 Dec 2006 19:32:29 -0500 + +bitpim (0.9.08.dfsg.1-1) unstable; urgency=medium + + * New upstream release; urgency medium because it fixes several bugs and + adds (at least partial) support for three more phone models. + * Comment out udev rules by default because they can make BitPim perform + full scans, which don't always terminate. + + -- Aaron M. Ucko Thu, 23 Nov 2006 15:40:35 -0500 + +bitpim (0.9.07.dfsg.1-1) unstable; urgency=medium + + * New upstream release; urgency medium due to bug fixes and the addition + of LGVX8500 (Chocolate) support. + * Adjust src/comm_notify.py to look for /var/*run*/bitpim/dnotify.log, + and deploy appropriate udev rules. (These rules are broad-sweeping, + but leave ownership and permissions alone.) + * Work around bogus OverflowErrors in comm_notify.py on 64-bit systems. + * Build with python-support 0.42, and drop the explicit python + dependency introduced to work around #383958. + + -- Aaron M. Ucko Thu, 7 Sep 2006 17:46:36 -0400 + +bitpim (0.9.06.dfsg.1-1) unstable; urgency=medium + + * New upstream release, mostly for bug fixes. + * Build with python-support 0.4.1 (dispensing with dh_python). + - give bitpim a direct dependency on python to avoid Lintian errors. + - lose debian/pycompat and the X-Python-Version: fields. + - loosen the build dependency on debhelper. + + -- Aaron M. Ucko Fri, 11 Aug 2006 18:41:36 -0400 + +bitpim (0.9.05.dfsg.1-1) unstable; urgency=medium + + * New upstream release; adds SCH-A930 support, avoids hanging upon exit, + and includes other safe improvements. + * Build-depend on debhelper >= 5.0.37.3 to keep bitpim-lib from hitting + bug #375948 (wrong metadata for private extensions). + + -- Aaron M. Ucko Sun, 16 Jul 2006 16:35:59 -0400 + +bitpim (0.9.04.dfsg.1-1) unstable; urgency=medium + + * New upstream release; adds preliminary VX8300 support and some safe + bugfixes. + * Don't try to run ffmpeg with -hq, which not all versions recognize + even if they actually support mp3 output. (Closes: #375600.) + * Update pointer to unofficial ffmpeg packages in README.Debian. + * Bump debian/compat to 5 on principle; should be a no-op here, though. + + -- Aaron M. Ucko Wed, 28 Jun 2006 19:36:14 -0400 + +bitpim (0.9.03.dfsg.1-1) unstable; urgency=medium + + * New upstream release, mostly for bugfixes. + * Explicitly request new dh_python behavior via debian/pycompat ("2"). + + -- Aaron M. Ucko Fri, 23 Jun 2006 20:31:05 -0400 + +bitpim (0.9.02.dfsg.1-2) unstable; urgency=low + + * Update for new (0.4) Python policy, using python-support (unfixing + #358023 for the moment, but so be it), with additional logic to ensure + that BitPim's own code remains available in optimized (.pyo) form. + + -- Aaron M. Ucko Thu, 15 Jun 2006 18:10:49 -0400 + +bitpim (0.9.02.dfsg.1-1) unstable; urgency=medium + + * New upstream release (0.9.01 skipped due to bugs); urgency medium + because the set of supported phones has grown yet again. + + -- Aaron M. Ucko Wed, 7 Jun 2006 08:53:55 -0400 + +bitpim (0.9.00.dfsg.1-1) unstable; urgency=medium + + * New upstream milestone release. + + -- Aaron M. Ucko Wed, 17 May 2006 18:09:41 -0400 + +bitpim (0.8.14.dfsg.1-1) unstable; urgency=medium + + * New upstream release; urgency medium due to added support for further + phone models. + * Adjust for bmp2avi's new makefile, which buildmodules.py can now use. + * Require python-apsw >= 3.3.5r1 per upstream. + * Standards-Version: 3.7.2 (still no changes required). + + -- Aaron M. Ucko Tue, 9 May 2006 20:21:24 -0400 + +bitpim (0.8.13.dfsg.1-2) unstable; urgency=low + + * Stop patching brewcompressedimage.py in favor of depending on a + version of python-wxgtk2.6 new enough to support what upstream ships. + * Standards-Version: 3.7.1 (no changes required). + + -- Aaron M. Ucko Wed, 3 May 2006 20:49:30 -0400 + +bitpim (0.8.13.dfsg.1-1) unstable; urgency=medium + + * New upstream release; urgency medium because it fixes some + moderately annoying bugs and adds support for yet more phones. + * README.Debian: drop note about udev configuration, which upstream's + own documentation now addresses. + * Install upstream's (new) .desktop file. + + -- Aaron M. Ucko Tue, 25 Apr 2006 21:08:19 -0400 + +bitpim (0.8.12.dfsg.1-2) unstable; urgency=medium + + * The "I just shot myself in the foot, didn't I?" release. + * Add a symlink to work around python-support bug #363505, which + interferes with bitpim's ability to find python-dsv 1.4.0-2. + + -- Aaron M. Ucko Wed, 19 Apr 2006 19:07:05 -0400 + +bitpim (0.8.12.dfsg.1-1) unstable; urgency=medium + + * New upstream release; urgency medium due to interface bug fixes and + new (partial) support for one more phone model. + * Merge bitfling into the main bitpim package, as there wasn't actually + much point in keeping it separate. + + -- Aaron M. Ucko Sun, 16 Apr 2006 12:23:56 -0400 + +bitpim (0.8.11.dfsg.1-1) unstable; urgency=medium + + * New upstream release; urgency medium because it offers significant + improvements over previous versions, including support for four + additional phone models. + * Adjust packaging to reflect new upstream layout (and avoid version + skew between bitpim and bitfling). + * Fix typo in bitfling's short description. (Closes: #357647.) + * Optimize debian/rules slightly; in particular, take advantage of + upstream's new buildmodules.py script. + * Byte-compile bitpim's .py files with -Wignore to suppress + FutureWarnings that upstream characterizes as spurious. (Closes: + #358023.) + * Make a couple of minor corrections to debian/copyright per upstream's + feedback. + + -- Aaron M. Ucko Sat, 8 Apr 2006 17:38:46 -0400 + +bitpim (0.8.08.dfsg.2-3) unstable; urgency=low + + * Increase optimization to -OO per upstream's recommendation. + * README.Debian: Advise users that stock Debian systems do not support + encoding ringtones into the MP3 format due to patent concerns. + + -- Aaron M. Ucko Fri, 17 Mar 2006 18:34:10 -0500 + +bitpim (0.8.08.dfsg.2-2) unstable; urgency=low + + * More fixes to debian/copyright; in particular, spell the wxWidgets + license that applies to some components out rather than merely citing + it. + + -- Aaron M. Ucko Mon, 27 Feb 2006 19:38:51 -0500 + +bitpim (0.8.08.dfsg.2-1) unstable; urgency=low + + * New upstream tarball, with the outlook plugin removed on the grounds + of being useless on Unix and possibly derived from non-free code. + * Document remaining non-GPLed components' (GPL-compatible!) licenses in + debian/copyright. + + -- Aaron M. Ucko Sun, 26 Feb 2006 19:35:23 -0500 + +bitpim (0.8.08.dfsg.1-1) unstable; urgency=low + + * New upstream release, extracted from upstream CVS as before. + * Supply a plain-text version of upstream's changelog. + + -- Aaron M. Ucko Wed, 22 Feb 2006 14:06:07 -0500 + +bitpim (0.8.07.dfsg.1-1) unstable; urgency=low + + * Initial release, from an upstream CVS checkout with prebuilt binaries + removed. (Closes: #265585.) + * Backported brewcompressedimage.py to wxPython 2.6.1, as Debian does + not yet provide a newer version (thanks to #342189). + + -- Aaron M. Ucko Tue, 7 Feb 2006 18:46:22 -0500 + --- bitpim-1.0.2.dfsg.1.orig/debian/pyversions +++ bitpim-1.0.2.dfsg.1/debian/pyversions @@ -0,0 +1 @@ +2.4- --- bitpim-1.0.2.dfsg.1.orig/debian/bitfling.sh +++ bitpim-1.0.2.dfsg.1/debian/bitfling.sh @@ -0,0 +1,2 @@ +#!/bin/sh +exec /usr/bin/python -OO /usr/share/bitpim/code/bp.py bitfling "$@" --- bitpim-1.0.2.dfsg.1.orig/debian/compat +++ bitpim-1.0.2.dfsg.1/debian/compat @@ -0,0 +1 @@ +5 --- bitpim-1.0.2.dfsg.1.orig/debian/bitfling.1 +++ bitpim-1.0.2.dfsg.1/debian/bitfling.1 @@ -0,0 +1,23 @@ +.TH BITFLING 1 "2006-02-04" +.SH NAME +bitfling \- secure remote access to BitFling +.SH SYNOPSIS +.B bitfling +.SH DESCRIPTION +This manual page documents briefly the +.B bitfling +command. +.PP +BitFling lets BitPim run on one machine while your phone is connected +to a different machine, even across the Internet. It uses a protocol +over a secure connection to ensure this is safe. +.SH OPTIONS +None. +.SH SEE ALSO +.BR bitpim (1), +http://www.bitpim.org/. +.SH AUTHOR +\fBbitfling\fP was primarily written by Roger Binns . +.PP +This manual page was written by Aaron M. Ucko , +for the Debian project (but may be used by others). --- bitpim-1.0.2.dfsg.1.orig/debian/bitpim.install +++ bitpim-1.0.2.dfsg.1/debian/bitpim.install @@ -0,0 +1,7 @@ +etc/default/bitpim +lib/udev/bpudev +usr/bin/bitfling +usr/bin/bitpim +usr/share/applications +usr/share/bitpim +usr/share/pixmaps --- bitpim-1.0.2.dfsg.1.orig/debian/README.Debian +++ bitpim-1.0.2.dfsg.1/debian/README.Debian @@ -0,0 +1,29 @@ +BitPim for Debian +================= + +device permissions +------------------ +I second the upstream developers' recommendation of running BitPim as +a regular user rather than root. However, for this to be possible, +you will probably first need to configure appropriate device +permissions. If your system runs udev (installed by default) and you +have a USB-connected phone that BitPim fully recognizes, it should +suffice to edit the settings in /etc/default/bitpim according to that +file's comments. Otherwise, you can define local rules akin to those +in /etc/udev/rules.d/z60_bitpim.rules. + +mp3 ringtones +------------- +Many of the phones BitPim supports allow users to upload ringtones in +the popular MP3 format. Although BitPim offers to convert WAV files +to this format, please be advised that such conversion *will not work* +on a stock Debian system, as patent concerns prevent Debian from +distributing any MP3 encoders via official channels. + +On the other hand, uploading existing MP3 (or, for that matter, MIDI) +ringtones as is should still work. Moreover, you can ease this +restriction by installing an unofficial version of the ffmpeg package +with support for MP3 encoding; at the time of this writing, +http://www.debian-multimedia.org/ has such packages. + + -- Aaron M. Ucko , Sat, 10 Nov 2007 18:38:59 -0500 --- bitpim-1.0.2.dfsg.1.orig/debian/bitpim.default +++ bitpim-1.0.2.dfsg.1/debian/bitpim.default @@ -0,0 +1,16 @@ +# -*- shell-script -*- + +# If you would like USB devices that BitPim supports to have specific +# ownership settings, you can specify them here. (For instance, you +# can assign all such devices to the appropriate user account, or to +# the standard group dialout, or to a custom group such as cellusers.) +# If you leave these blank, BitPim will leave their ownership alone +# (root:root by default). + +BPUDEV_USER= +BPUDEV_GROUP= + +# You can also specify Unix permissions for the devices, though the +# default should be reasonable in most cases. + +# BPUDEV_MODE=0664 --- bitpim-1.0.2.dfsg.1.orig/debian/copyright +++ bitpim-1.0.2.dfsg.1/debian/copyright @@ -0,0 +1,203 @@ +This package was debianized by Aaron M. Ucko on +Fri, 3 Feb 2006 18:28:52 -0500. + +It was downloaded from http://www.bitpim.org/ + +Copyright Holder: Roger Binns and others + +License: + Copyright (C) 2003-2006 Roger Binns and others - see http://www.bitpim.org/ + + This package is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This package is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this package; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + In addition, as a special exception, the BitPim copyright holders + give permission to link the code of this program with the OpenSSL + library (or with modified versions of OpenSSL), and distribute + linked combinations including the two. You must obey the GNU + General Public License in all respects for all of the code used + other than OpenSSL. If you modify any files, you may extend this + exception to your version of the file, but you are not obligated to + do so. If you do not wish to do so, delete this exception statement + from your version. + +On Debian systems, the complete text of the GNU General Public +License, version 2, can be found in +`/usr/share/common-licenses/GPL-2'. + +Please also note that some code is taken from other projects with a +GPL compatible license. In alphabetical order by file: + +* src/bitfling/xmlrpcstuff.py is double licensed as the BitPim License + [above] and the standard Python license [1]. It incorporates code + from the standard Python library which was then modified to work + properly. + +* src/fixedscrollpanel.py and fixedwxpTag.py fall under the wxWidgets + license [2]: the GNU LGPL v2+ with a static-linking exception. + +* src/native/usb/libusb.i falls under the GNU Library/Lesser General + Public License, which can be found in `/usr/share/common-licenses/LGPL'. + +* src/native/usb/usb.py is in the public domain. + +* src/xyaptu.py is licensed under the BSD license, which can be found in + `/usr/share/common-licenses/BSD'. + +[1] This is the Python license. In short, you can use this product in +commercial and non-commercial applications, modify it, redistribute it. +A notification to the author when you use and/or modify it is welcome. + + +TERMS AND CONDITIONS FOR ACCESSING OR OTHERWISE USING THIS SOFTWARE +=================================================================== + +LICENSE AGREEMENT +----------------- + +1. This LICENSE AGREEMENT is between the copyright holder of this +product, and the Individual or Organization ("Licensee") accessing +and otherwise using this product in source or binary form and its +associated documentation. + +2. Subject to the terms and conditions of this License Agreement, +the copyright holder hereby grants Licensee a nonexclusive, +royalty-free, world-wide license to reproduce, analyze, test, +perform and/or display publicly, prepare derivative works, distribute, +and otherwise use this product alone or in any derivative version, +provided, however, that copyright holders License Agreement and +copyright holders notice of copyright are retained in this product +alone or in any derivative version prepared by Licensee. + +3. In the event Licensee prepares a derivative work that is based on +or incorporates this product or any part thereof, and wants to make +the derivative work available to others as provided herein, then +Licensee hereby agrees to include in any such work a brief summary of +the changes made to this product. + +4. The copyright holder is making this product available to Licensee on +an "AS IS" basis. THE COPYRIGHT HOLDER MAKES NO REPRESENTATIONS OR +WARRANTIES, EXPRESS OR IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, +THE COPYRIGHT HOLDER MAKES NO AND DISCLAIMS ANY REPRESENTATION OR +WARRANTY OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR +THAT THE USE OF THIS PRODUCT WILL NOT INFRINGE ANY THIRD PARTY RIGHTS. + +5. THE COPYRIGHT HOLDER SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER +USERS OF THIS PRODUCT FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL +DAMAGES OR LOSS AS A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE +USING THIS PRODUCT, OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE +POSSIBILITY THEREOF. + +6. This License Agreement will automatically terminate upon a material +breach of its terms and conditions. + +7. Nothing in this License Agreement shall be deemed to create any +relationship of agency, partnership, or joint venture between the +copyright holder and Licensee. This License Agreement does not grant +permission to use trademarks or trade names from the copyright holder +in a trademark sense to endorse or promote products or services of +Licensee, or any third party. + +8. By copying, installing or otherwise using this product, Licensee +agrees to be bound by the terms and conditions of this License +Agreement. + +[2] +Preamble +======== + +The licensing of the wxWindows library is intended to protect the wxWindows +library, its developers, and its users, so that the considerable investment +it represents is not abused. + +Under the terms of the wxWindows Licence, you as a user are not +obliged to distribute wxWindows source code with your products, if you +distribute these products in binary form. However, you are prevented from +restricting use of the library in source code form, or denying others the +rights to use or distribute wxWindows library source code in the way +intended. + +The wxWindows Licence establishes the copyright for the code and related +material, and it gives you legal permission to copy, distribute and/or +modify the library. It also asserts that no warranty is given by the authors +for this or derived code. + +The core distribution of the wxWindows library contains files +under two different licences: + +- Most files are distributed under the GNU Library General Public + Licence, version 2, with the special exception that you may create and + distribute object code versions built from the source code or modified + versions of it (even if these modified versions include code under a + different licence), and distribute such binaries under your own + terms. + +- Most core wxWindows manuals are made available under the "wxWindows + Free Documentation Licence", which allows you to distribute modified + versions of the manuals, such as versions documenting any modifications + made by you in your version of the library. However, you may not restrict + any third party from reincorporating your changes into the original + manuals. + + wxWindows Library Licence, Version 3 + ==================================== + + Copyright (c) 1998 Julian Smart, Robert Roebling et al + + Everyone is permitted to copy and distribute verbatim copies + of this licence document, but changing it is not allowed. + + WXWINDOWS LIBRARY LICENCE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU Library General Public Licence as published by + the Free Software Foundation; either version 2 of the Licence, or (at + your option) any later version. + + This library is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library + General Public Licence for more details. + + You should have received a copy of the GNU Library General Public Licence + along with this software, usually in a file named COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + Boston, MA 02110-1301 USA. + + EXCEPTION NOTICE + + 1. As a special exception, the copyright holders of this library give + permission for additional uses of the text contained in this release of + the library as licenced under the wxWindows Library Licence, applying + either version 3 of the Licence, or (at your option) any later version of + the Licence as published by the copyright holders of version 3 of the + Licence document. + + 2. The exception is that you may use, copy, link, modify and distribute + under the user's own terms, binary object code versions of works based + on the Library. + + 3. If you copy code from files distributed under the terms of the GNU + General Public Licence or the GNU Library General Public Licence into a + copy of this library, as this licence permits, the exception does not + apply to the code that you add in this way. To avoid misleading anyone as + to the status of such modified files, you must delete this exception + notice from such code and/or adjust the licensing conditions notice + accordingly. + + 4. If you write modifications of your own for this library, it is your + choice whether to permit this exception to apply to your modifications. + If you do not wish that, you must delete the exception notice from such + code and/or adjust the licensing conditions notice accordingly. --- bitpim-1.0.2.dfsg.1.orig/debian/bitpim.postinst +++ bitpim-1.0.2.dfsg.1/debian/bitpim.postinst @@ -0,0 +1,21 @@ +#!/bin/sh +set -e + +#DEBHELPER# + +# Standard tools just arrange to produce unoptimized .pyc files; ensure +# that we also have optimized .pyo files for better performance. +# Also, supply -Wignore to suppress spurious FutureWarnings. (See #358023.) + +if test -x /usr/bin/pyversions; then + PYTHON=`pyversions -d` +else + PYTHON=python2.3 +fi + +if which $PYTHON >/dev/null 2>&1 && [ -e /usr/lib/$PYTHON/compileall.py ]; then + # $PYTHON -Wignore /usr/lib/$PYTHON/compileall.py -q /usr/share/bitpim + $PYTHON -OO -Wignore /usr/lib/$PYTHON/compileall.py -q /usr/share/bitpim/code +fi + +exit 0 --- bitpim-1.0.2.dfsg.1.orig/debian/bitpim.manpages +++ bitpim-1.0.2.dfsg.1/debian/bitpim.manpages @@ -0,0 +1,2 @@ +debian/bitfling.1 +debian/bitpim.1 --- bitpim-1.0.2.dfsg.1.orig/debian/bitpim-lib.install +++ bitpim-1.0.2.dfsg.1/debian/bitpim-lib.install @@ -0,0 +1 @@ +usr/lib/bitpim --- bitpim-1.0.2.dfsg.1.orig/resources/bpudev +++ bitpim-1.0.2.dfsg.1/resources/bpudev @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh ### ### BITPIM ### @@ -14,6 +14,13 @@ # $3=SYSFS{devnum} # +if [ "x$1" = "x--del" ]; then + action=del + shift +else + action=add +fi + # Some basic checking for args if [ $# -ne 3 ]; then exit 1 @@ -22,18 +29,28 @@ # udev fires off a whole bunch of devices, most of which we don't need. # By visual inspection, the one that we want has the same Kernel No and # SYSFS{devnum}. +# XXX - this appears to fail for removals. :-/ if [ "$2" != "$3" ]; then exit 2 fi -# Change the device file group to "cellusers", if such group exists. -chgrp cellusers "$1" || true -# ensure the proper permission -chmod 0664 "$1" || true +BPUDEV_USER= +BPUDEV_GROUP= +BPUDEV_MODE=0664 + +if test -r /etc/default/bitpim; then + . /etc/default/bitpim +fi + +if [ "$action" = "add" ]; then + [ -z "$BPUDEV_USER" ] || chown "$BPUDEV_USER" "$1" || true + [ -z "$BPUDEV_GROUP" ] || chgrp "$BPUDEV_GROUP" "$1" || true + chmod "$BPUDEV_MODE" "$1" || true +fi # Notify BitPim that there's a new USB device -if [ ! -d /var/bitpim ] +if [ ! -d /var/run/bitpim ] then - mkdir /var/bitpim + mkdir /var/run/bitpim fi -echo add $1 > /var/bitpim/dnotify.log +echo $action $1 > /var/run/bitpim/dnotify.log --- bitpim-1.0.2.dfsg.1.orig/packaging/buildmodules.py +++ bitpim-1.0.2.dfsg.1/packaging/buildmodules.py @@ -35,7 +35,7 @@ if "usb" in args: # USB print "===== src/native/usb" - if sys.platform in ('darwin', 'linux2'): + if sys.platform != 'win32': os.chdir("src/native/usb") if os.path.exists("_libusb.so"): os.remove("_libusb.so") @@ -68,9 +68,12 @@ if "bmp2avi" in args: # BMP2AVI convertor print "==== src/native/av/bmp2avi" - fname={'linux2': 'bmp2avi.lbin', - 'darwin': 'bmp2avi.mbin', - 'win32': 'bmp2avi.exe'}[sys.platform] + if sys.platform.startswith('gnukfreebsd'): + fname='bmp2avi.lbin' + else: + fname={'linux2': 'bmp2avi.lbin', + 'darwin': 'bmp2avi.mbin', + 'win32': 'bmp2avi.exe'}[sys.platform] if os.path.exists(os.path.join("helpers", fname)): os.remove(os.path.join("helpers", fname)) os.chdir("src/native/av/bmp2avi")