#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# hylaPEx, an hylafax client written in python
#
# www.unipex.it/hylapex/
#
# License:
# GNU General Public License (GPL)
# For more info see LICENSE.txt and LICENSE-GPL.txt
#
# Copyright (C) 2004-2006 Unipex s.r.l., All Rights Reserved.
# Via Vittorio Veneto 83/A
# 33050 Gonars (UD) - Italy
# phone 0039 0432 931511 - fax 0039 0432 931378
# www.unipex.it - michele.petrazzo@unipex.it
import os
from library.ftp import read_conf
VIEW_DONE = 0
VIEW_RECEIVE = 1
VIEW_SEND = 2
class l:
def __init__(self, paths):
self.my_path_conf = paths.conf_dir
for view_name, view in zip( ('send', 'done', 'receive'), (VIEW_SEND, VIEW_DONE, VIEW_RECEIVE) ):
file_name = os.path.join(self.my_path_conf, 'dim_' + view_name + '.conf')
conf = read_conf.conf(file_name, '', '')
if conf.exist():
continue
dta = conf.read()
#print dta
self.set(view, dta)
class send:
text = {'id':'Id','stat':'Status','own':'Owner','num':'Number',
'pag':'Page Trasf.','dial':'Dials','stat':'Status','tts':'Time to send',
'comp':'Company','pri':'Pri', 'last': 'Last situation','sched':'Next scheduler',
'descr':'In invio', 'rate':'Send rate', 'loc': 'Location', 'to_pers':'To person'}
dim = {'id':70, 'stat':70, 'own':70, 'num':80,'pag':70,'dial':50,'stat':70,'tts':90,
'comp': 90, 'pri':40, 'kill':50, 'last': 150,'sched': 100,'rate':60, 'loc': 70,
'to_pers': 90}
val = {'comp':'C','dial':'D','pri':'I','jtag':'J','stat':'a','num':'e','id':'j','own':'o',
'last':'s','kill':'k','pag':'P','tts':'z', 'sched':'Z', 'rate':'E', 'loc': 'L',
'to_pers':'R'}
order = ['id','comp','to_pers', 'pri','own','stat','dial','num','pag','tts','last']
class receive:
text = {'img':'Image', 'page':'Pages', 'snd':'Sender', 'dat':'Date',
'descr':'Ricevuti', 'err':'Error'}
dim = {'img':120, 'page':50, 'snd':150, 'dat':80, 'err':100}
val = {'err':'e', 'img':'f', 'page':'p','snd':'s', 'dat':'t', 'err':'e'}
order = ['img','page','snd','dat','err']
class done:
text = {'id':'Id', 'pri':'Priority', 'stat':'Status', 'own':'Owner',
'num':'Number', 'pag':'Pag', 'call':'Call', 'dat':'Date', 'last':'Last situation',
'comp':'Company','descr':'Inviati','rate':'Velocita', 'tts':'Tempo trasmiss.',
'loc': 'Location', 'to_pers':'To person'}
dim = {'id':35, 'pri':45, 'stat':50, 'own':60,'num':100, 'pag':40, 'call':60,
'dat':90, 'last':200,'comp':140,'rate':60,'tts':80, 'loc': 70, 'to_pers': 90}
val = {'comp':'C','dial':'D','pri':'I','jtag':'J','stat':'a','num':'e','id':'j','own':'o',
'last':'s','kill':'k','pag':'p','dat':'Y','rate':'E', 'tts':'z', 'loc': 'L',
'to_pers':'R'}
order = ['id', 'comp','dat','to_pers' ,'own','stat','num','pag','pri','last', ]
class other:
text = {'send': {'stat':{'F':'Failed','B':'Bloccato','D':'Ok','T':"Sospeso dall'utente", 'R': 'Pronto', 'S': 'Attesa di invio',
'P': 'Attesa di invio', 'W': 'Attesa modem'},
'pri' : {'127':'media','255': 'alta'},
'last' : {'No local dialtone':'Manca linea locale','Busy signal detected':'Occupato',\
'No carrier detected': 'Linea remota assente', 'Job interrupted by user':'Fax interrotto manualmente',
'Blocked by concurrent calls':'Bloccato da altro invio - stessa destinazione', }
},
'done': {'stat': {'F':'Failed','B':'Bloccato','D':'Ok'},
'pri' : {'127':'media','255': 'alta'},
'last' : {'No local dialtone; too many attempts to dial':'Manca linea locale; troppi tentativi effettuati',\
'Busy signal detected':'Occupato', 'No carrier detected': 'Linea remota assente',\
'Busy signal detected; too many attempts to dial':'Occupato; troppi tentativi effettuati',
'Kill time expired':'Tempo massimo superato'}
},
'receive': {
}
}
def ret(self, view):
if view == VIEW_RECEIVE:
return self.receive.text, self.receive.dim, self.receive.val, self.receive.order
elif view == VIEW_DONE:
return self.done.text, self.done.dim, self.done.val, self.done.order
elif view == VIEW_SEND:
return self.send.text, self.send.dim, self.send.val, self.send.order
elif view == 'other':
return self.other.text
def set(self, view, spec, cl = 'dim'):
if view == VIEW_RECEIVE:
if cl == 'dim':
for val in spec:
self.receive.dim[val] = int(spec[val])
elif view == VIEW_DONE:
if cl == 'dim':
for val in spec:
self.done.dim[val] = int(spec[val])
elif view == VIEW_SEND:
if cl == 'dim':
for val in spec:
self.send.dim[val] = int(spec[val])
elif view == 'other':
return
def save_pref(self):
for view in ['send', 'done', 'receive']:
file_name = os.path.join(self.my_path_conf, 'dim_' + view + '.conf')
conf = read_conf.conf(file_name, '', '')
if view == 'receive':
conf.write(self.receive.dim)
elif view == 'done':
conf.write(self.done.dim)
elif view == 'send':
conf.write(self.send.dim)
|