Make a main class OfflineImap that is being called
Rather than calling a function in a module, invoke offlineimap by calling an OfflineImap object. This removes code lying outside of objects; I prefer to keep code within an object and provides us with a nicer Object encapsulation. It will also ease the testing of Object functionality in unittests when they are introduced. Previously we would import and start Offlineimap like this: from offlineimap import init init.startup('6.2.0') now we do: from offlineimap import OfflineImap offlineimap = OfflineImap() offlineimap.startup('6.2.0') Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de> Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
parent
35dd236155
commit
325dd833ba
@ -17,5 +17,7 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
from offlineimap import init
|
from offlineimap import OfflineImap
|
||||||
init.startup('6.2.0')
|
|
||||||
|
offlineimap = OfflineImap()
|
||||||
|
offlineimap.startup('6.2.0')
|
||||||
|
@ -17,5 +17,7 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
from offlineimap import init
|
from offlineimap import OfflineImap
|
||||||
init.startup('6.2.0')
|
|
||||||
|
offlineimap = OfflineImap()
|
||||||
|
offlineimap.startup('6.2.0')
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
from offlineimap.init import OfflineImap
|
||||||
|
|
||||||
__all__ = ['ui', 'folder', 'repository', 'mbnames', 'threadutil', 'init']
|
__all__ = ['ui', 'folder', 'repository', 'mbnames', 'threadutil', 'init']
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,7 +36,9 @@ except:
|
|||||||
|
|
||||||
lockfd = None
|
lockfd = None
|
||||||
|
|
||||||
def lock(config, ui):
|
class OfflineImap:
|
||||||
|
|
||||||
|
def lock(self, config, ui):
|
||||||
global lockfd, hasfcntl
|
global lockfd, hasfcntl
|
||||||
if not hasfcntl:
|
if not hasfcntl:
|
||||||
return
|
return
|
||||||
@ -47,7 +49,7 @@ def lock(config, ui):
|
|||||||
ui.locked()
|
ui.locked()
|
||||||
ui.terminate(1)
|
ui.terminate(1)
|
||||||
|
|
||||||
def startup(versionno):
|
def startup(self, versionno):
|
||||||
assert versionno == version.versionstr, "Revision of main program (%s) does not match that of library (%s). Please double-check your PYTHONPATH and installation locations." % (versionno, version.versionstr)
|
assert versionno == version.versionstr, "Revision of main program (%s) does not match that of library (%s). Please double-check your PYTHONPATH and installation locations." % (versionno, version.versionstr)
|
||||||
options = {}
|
options = {}
|
||||||
options['-k'] = []
|
options['-k'] = []
|
||||||
@ -133,9 +135,10 @@ def startup(versionno):
|
|||||||
config.set(section, "folderfilter", folderfilter)
|
config.set(section, "folderfilter", folderfilter)
|
||||||
config.set(section, "folderincludes", folderincludes)
|
config.set(section, "folderincludes", folderincludes)
|
||||||
|
|
||||||
lock(config, ui)
|
self.lock(config, ui)
|
||||||
|
|
||||||
def sigterm_handler(signum, frame):
|
|
||||||
|
def sigterm_handler(self, signum, frame):
|
||||||
# die immediately
|
# die immediately
|
||||||
ui.terminate(errormsg="terminating...")
|
ui.terminate(errormsg="terminating...")
|
||||||
signal.signal(signal.SIGTERM,sigterm_handler)
|
signal.signal(signal.SIGTERM,sigterm_handler)
|
||||||
|
Loading…
Reference in New Issue
Block a user