Machine now runs
This commit is contained in:
parent
f9d01fb35e
commit
c6f01fb3c8
@ -16,41 +16,71 @@
|
|||||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
import offlineimap.version
|
import offlineimap.version
|
||||||
import urllib
|
import urllib, sys, re, time, traceback, threading, thread
|
||||||
|
from UIBase import UIBase
|
||||||
from threading import *
|
from threading import *
|
||||||
|
|
||||||
class MachineParsable(UIBase):
|
protocol = '6.0.0'
|
||||||
|
|
||||||
|
class MachineUI(UIBase):
|
||||||
def __init__(s, config, verbose = 0):
|
def __init__(s, config, verbose = 0):
|
||||||
UIBase.__init__(s, config, verbose)
|
UIBase.__init__(s, config, verbose)
|
||||||
|
s.safechars=" ;,./-_=+"
|
||||||
s.iswaiting = 0
|
s.iswaiting = 0
|
||||||
s.outputlock = Lock()
|
s.outputlock = Lock()
|
||||||
|
s._printData('__init__', protocol)
|
||||||
|
|
||||||
def isusable(s):
|
def isusable(s):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _printData(s, command, data, dolock = True):
|
def _printData(s, command, data, dolock = True):
|
||||||
s._printDataOut(s, 'msg', command, data, dolock)
|
s._printDataOut('msg', command, data, dolock)
|
||||||
|
|
||||||
def _printWarn(s, command, data, dolock = True):
|
def _printWarn(s, command, data, dolock = True):
|
||||||
s._printDataOut(s, 'warn', command, data, dolock)
|
s._printDataOut('warn', command, data, dolock)
|
||||||
|
|
||||||
def _printDataOut(s, datatype, command, data, dolock = True):
|
def _printDataOut(s, datatype, command, data, dolock = True):
|
||||||
if dolock:
|
if dolock:
|
||||||
s.outputlock.acquire()
|
s.outputlock.acquire()
|
||||||
try:
|
try:
|
||||||
print "%s\n%s\n%s\n%s\n" % \
|
print "%s:%s:%s:%s" % \
|
||||||
(datatype,
|
(datatype,
|
||||||
urllib.quote(command, ' '),
|
urllib.quote(command, s.safechars),
|
||||||
urllib.quote(currentThread().getName(), ' '),
|
urllib.quote(currentThread().getName(), s.safechars),
|
||||||
urllib.quote(data, ' '))
|
urllib.quote(data, s.safechars))
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
finally:
|
finally:
|
||||||
if dolock:
|
if dolock:
|
||||||
s.outputlock.release()
|
s.outputlock.release()
|
||||||
|
|
||||||
|
def _display(s, msg):
|
||||||
|
s._printData('_display', msg)
|
||||||
|
|
||||||
|
def warn(s, msg, minor):
|
||||||
|
s._printData('warn', '%s\n%d' % (msg, int(minor)))
|
||||||
|
|
||||||
|
def registerthread(s, account):
|
||||||
|
UIBase.registerthread(s, account)
|
||||||
|
s._printData('registerthread', account)
|
||||||
|
|
||||||
|
def unregisterthread(s, thread):
|
||||||
|
UIBase.unregisterthread(s, thread)
|
||||||
|
s._printData('unregisterthread', thread.getName())
|
||||||
|
|
||||||
|
def debugging(s, debugtype):
|
||||||
|
s._printData('debugging', debugtype)
|
||||||
|
|
||||||
def acct(s, accountname):
|
def acct(s, accountname):
|
||||||
s._printData('acct', accountname)
|
s._printData('acct', accountname)
|
||||||
|
|
||||||
|
def acctdone(s, accountname):
|
||||||
|
s._printData('acctdone', accountname)
|
||||||
|
|
||||||
|
def validityproblem(s, folder):
|
||||||
|
s._printData('validityproblem', "%s\n%s\n%s\n%s" % \
|
||||||
|
(folder.getname(), folder.getrepository().getname(),
|
||||||
|
folder.getsaveduidvalidity(), folder.getuidvalidity()))
|
||||||
|
|
||||||
def connecting(s, hostname, port):
|
def connecting(s, hostname, port):
|
||||||
s._printData('connecting', "%s\n%s" % (hostname, str(port)))
|
s._printData('connecting', "%s\n%s" % (hostname, str(port)))
|
||||||
|
|
||||||
@ -67,6 +97,10 @@ class MachineParsable(UIBase):
|
|||||||
s._printData('loadmessagelist', "%s\n%s" % (s.getnicename(repos),
|
s._printData('loadmessagelist', "%s\n%s" % (s.getnicename(repos),
|
||||||
folder.getvisiblename()))
|
folder.getvisiblename()))
|
||||||
|
|
||||||
|
def messagelistloaded(s, repos, folder, count):
|
||||||
|
s._printData('messagelistloaded', "%s\n%s\n%d" % \
|
||||||
|
(s.getnicename(repos), folder.getname(), count))
|
||||||
|
|
||||||
def syncingmessages(s, sr, sf, dr, df):
|
def syncingmessages(s, sr, sf, dr, df):
|
||||||
s._printData('syncingmessages', "%s\n%s\n%s\n%s\n" % \
|
s._printData('syncingmessages', "%s\n%s\n%s\n%s\n" % \
|
||||||
(s.getnicename(sr), sf.getname(), s.getnicename(dr),
|
(s.getnicename(sr), sf.getname(), s.getnicename(dr),
|
||||||
@ -75,7 +109,7 @@ class MachineParsable(UIBase):
|
|||||||
def copyingmessage(s, uid, src, destlist):
|
def copyingmessage(s, uid, src, destlist):
|
||||||
ds = s.folderlist(destlist)
|
ds = s.folderlist(destlist)
|
||||||
s._printData('copyingmessage', "%d\n%s\n%s\n%s" % \
|
s._printData('copyingmessage', "%d\n%s\n%s\n%s" % \
|
||||||
(uid, s.getnicename(src), src.getname(), ds)
|
(uid, s.getnicename(src), src.getname(), ds))
|
||||||
|
|
||||||
def folderlist(s, list):
|
def folderlist(s, list):
|
||||||
return ("\f".join(["%s\t%s" % (s.getnicename(x), x.getname()) for x in list]))
|
return ("\f".join(["%s\t%s" % (s.getnicename(x), x.getname()) for x in list]))
|
||||||
@ -103,11 +137,16 @@ class MachineParsable(UIBase):
|
|||||||
ds))
|
ds))
|
||||||
|
|
||||||
def threadException(s, thread):
|
def threadException(s, thread):
|
||||||
|
print s.getThreadExceptionString(thread) #FIXME: remove
|
||||||
s._printData('threadException', "%s\n%s" % \
|
s._printData('threadException', "%s\n%s" % \
|
||||||
(thread.getName(), s.getThreadExceptionString(thread)))
|
(thread.getName(), s.getThreadExceptionString(thread)))
|
||||||
s.delThreadDebugLog(thread)
|
s.delThreadDebugLog(thread)
|
||||||
s.terminate(100)
|
s.terminate(100)
|
||||||
|
|
||||||
|
def terminate(s, exitstatus = 0, errortitle = '', errormsg = ''):
|
||||||
|
s._printData('terminate', "%d\n%s\n%s" % (exitstatus, errortitle, errormsg))
|
||||||
|
sys.exit(exitstatus)
|
||||||
|
|
||||||
def mainException(s):
|
def mainException(s):
|
||||||
s._printData('mainException', s.getMainExceptionString())
|
s._printData('mainException', s.getMainExceptionString())
|
||||||
|
|
||||||
@ -122,12 +161,6 @@ class MachineParsable(UIBase):
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def getpass(s, accountname, config, errmsg = None):
|
def getpass(s, accountname, config, errmsg = None):
|
||||||
s.outputlock.acquire()
|
s.outputlock.acquire()
|
||||||
try:
|
try:
|
||||||
@ -139,4 +172,6 @@ class MachineParsable(UIBase):
|
|||||||
finally:
|
finally:
|
||||||
s.outputlock.release()
|
s.outputlock.release()
|
||||||
|
|
||||||
|
def init_banner(s):
|
||||||
|
s._printData('initbanner', offlineimap.version.banner)
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
|
||||||
import UIBase, Blinkenlights
|
import UIBase, Blinkenlights, transmitter
|
||||||
try:
|
try:
|
||||||
import TTY
|
import TTY
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@ -31,6 +31,7 @@ else:
|
|||||||
import Curses
|
import Curses
|
||||||
|
|
||||||
import Noninteractive
|
import Noninteractive
|
||||||
|
import Machine
|
||||||
|
|
||||||
# Must be last
|
# Must be last
|
||||||
import detector
|
import detector
|
||||||
|
@ -20,7 +20,8 @@ import offlineimap.ui
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
DEFAULT_UI_LIST = ('Curses.Blinkenlights', 'TTY.TTYUI',
|
DEFAULT_UI_LIST = ('Curses.Blinkenlights', 'TTY.TTYUI',
|
||||||
'Noninteractive.Basic', 'Noninteractive.Quiet')
|
'Noninteractive.Basic', 'Noninteractive.Quiet',
|
||||||
|
'Machine.MachineUI')
|
||||||
|
|
||||||
def findUI(config, chosenUI=None):
|
def findUI(config, chosenUI=None):
|
||||||
uistrlist = list(DEFAULT_UI_LIST)
|
uistrlist = list(DEFAULT_UI_LIST)
|
||||||
|
Loading…
Reference in New Issue
Block a user