windows cli

This commit is contained in:
a-Sansara 2012-09-29 20:42:55 +02:00
parent 46bb274636
commit 193f425d66
8 changed files with 204 additions and 214 deletions

7
cmd.bat Normal file
View File

@ -0,0 +1,7 @@
@echo off
TITLE ImpraStorage (GNU GPLv3)
set cmd=''
set /P cmd=imprastorage %=%
set acmd=%cmd:"='%
imprastorage.exe %cmd%
cmd.bat

View File

@ -98,13 +98,11 @@ class Cli:
parser = _OptionParser() parser = _OptionParser()
parser.print_help = self.print_help parser.print_help = self.print_help
parser.print_usage = self.print_usage parser.print_usage = self.print_usage
self.wkpath = path+core.sep+'wk'+core.sep
gpData = OptionGroup(parser, '\n------------------------------------\ndata related Options (command data)') gpData = OptionGroup(parser, '')
gpConf = OptionGroup(parser, '\n------------------------------------\nconf related Options (command conf)') gpConf = OptionGroup(parser, '')
# metavar='<ARG1> <ARG2>', nargs=2 # metavar='<ARG1> <ARG2>', nargs=2
parser.add_option('-v', '--version' , help='show program\'s version number and exit' , action='store_true' , default=False)
parser.add_option('-q', '--quiet' , help='don\'t print status messages to stdout' , action='store_false', default=True) parser.add_option('-q', '--quiet' , help='don\'t print status messages to stdout' , action='store_false', default=True)
parser.add_option('-d', '--debug' , help='set debug mode' , action='store_true' , default=False) parser.add_option('-d', '--debug' , help='set debug mode' , action='store_true' , default=False)
@ -134,22 +132,14 @@ class Cli:
print() print()
if not a: if not a:
try :
if o.version :
self.print_header()
sys.exit(0)
except Exception as ex:
pass
try : try :
if not o.help : if not o.help :
parser.error(' no commando specified') self.parserError(' no commando specified')
sys.exit(1) else :
else : core.clear()
parser.print_help() parser.print_help()
except : except :
parser.error(' no commando specified') self.parserError(' no commando specified')
sys.exit(1)
else: else:
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -185,27 +175,32 @@ class Cli:
else : else :
if o.set_port and not util.represents_int(o.set_port): if o.set_port and not util.represents_int(o.set_port):
parser.error(' port must be a number') parser.error(' port must be a number')
sys.exit(1) self.exit(1)
if o.set_boxname: self.ini.set('box' , o.set_boxname,o.active_profile+'.imap') else :
if o.set_host: self.ini.set('host', o.set_host,o.active_profile+'.imap') if o.set_boxname: self.ini.set('box' , o.set_boxname,o.active_profile+'.imap')
if o.set_user: self.ini.set('user', o.set_user,o.active_profile+'.imap') if o.set_host: self.ini.set('host', o.set_host,o.active_profile+'.imap')
if o.set_pass: self.ini.set('pass', o.set_pass,o.active_profile+'.imap') if o.set_user: self.ini.set('user', o.set_user,o.active_profile+'.imap')
if o.set_port: self.ini.set('port', o.set_port,o.active_profile+'.imap') if o.set_pass: self.ini.set('pass', o.set_pass,o.active_profile+'.imap')
if o.set_name: self.ini.set('name', o.set_name,o.active_profile+'.infos') if o.set_port: self.ini.set('port', o.set_port,o.active_profile+'.imap')
if o.gen_key: if o.set_name: self.ini.set('name', o.set_name,o.active_profile+'.infos')
kg = crypt.KeyGen(256) if o.gen_key:
self.ini.set('key' ,kg.key,o.active_profile+'.keys') kg = crypt.KeyGen(256)
self.ini.set('mark',kg.mark,o.active_profile+'.keys') self.ini.set('key' ,kg.key,o.active_profile+'.keys')
self.ini.set('salt','-¤-ImpraStorage-¤-',o.active_profile+'.keys') self.ini.set('mark',kg.mark,o.active_profile+'.keys')
if self.check_profile(o.active_profile): self.ini.set('salt','-¤-ImpraStorage-¤-',o.active_profile+'.keys')
self.ini.set('profile', o.active_profile) if self.check_profile(o.active_profile):
self.ini.write() self.ini.set('profile', o.active_profile)
self.ini.print(o.active_profile) self.ini.write()
self.ini.print(o.active_profile)
elif o.check : elif o.check :
self.check_profile(o.check, True) self.check_profile(o.check, True)
else : else :
self.print_usage('') self.print_usage('')
elif a[0] == 'help':
core.clear()
parser.print_help()
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~ data CMD ~~ # ~~ data CMD ~~
@ -215,11 +210,12 @@ class Cli:
if self.check_profile(o.active_profile): if self.check_profile(o.active_profile):
core.clear()
self.print_header() self.print_header()
conf = core.ImpraConf(self.ini,o.active_profile) conf = core.ImpraConf(self.ini,o.active_profile)
impst = None impst = None
try: try:
impst = core.ImpraStorage(conf) impst = core.ImpraStorage(conf, False, self.wkpath)
except crypt.BadKeyException as e : except crypt.BadKeyException as e :
print() print()
Clz.print(' it seems that your current profile `' , Clz.fgB1, False) Clz.print(' it seems that your current profile `' , Clz.fgB1, False)
@ -232,13 +228,13 @@ class Cli:
remIndex = input(' remove index ? (yes/no) ') remIndex = input(' remove index ? (yes/no) ')
if remIndex.lower()=='yes': if remIndex.lower()=='yes':
Clz.print(' ',Clz.OFF) Clz.print(' ',Clz.OFF)
impst = core.ImpraStorage(conf, True) impst = core.ImpraStorage(conf, True, self.wkpath)
else : else :
print() print()
print(' bye') print(' bye')
print() print()
sys.exit(1) self.exit(1)
if a[0]=='list': if a[0]=='list':
@ -284,46 +280,46 @@ class Cli:
elif a[0] == 'add': elif a[0] == 'add':
if not len(a)>1 : self.error_cmd('`'+a[0]+' need at least one argument',parser) if not len(a)>1 : self.error_cmd('`'+a[0]+' need at least one argument',parser)
else:
vfile = a[1] vfile = a[1]
if util.file_exists(vfile) : if util.file_exists(vfile) :
if not len(a)>2 : if not len(a)>2 :
label, ext = core.splitext(core.basename(vfile)) label, ext = core.splitext(core.basename(vfile))
else: label = a[2] else: label = a[2]
if o.category is None : o.category = '' if o.category is None : o.category = ''
done = impst.addFile(vfile,label,o.category) done = impst.addFile(vfile,label,o.category)
if done : if done :
print('\n ',end='') print('\n ',end='')
Clz.print(' == OK == ', Clz.bg2+Clz.fgb7) Clz.print(' == OK == ', Clz.bg2+Clz.fgb7)
print() print()
else : self.error_cmd('`'+a[1]+' is not a file',parser) else : self.error_cmd('`'+a[1]+' is not a file',parser)
elif a[0] == 'get': elif a[0] == 'get':
if not len(a)>1 : self.error_cmd('`'+a[0]+' need one argument',parser) if not len(a)>1 : self.error_cmd('`'+a[0]+' need one argument',parser)
else:
vid = a[1] vid = a[1]
ids = [] ids = []
for sid in vid.split(',') : for sid in vid.split(',') :
seq = sid.split('-') seq = sid.split('-')
if len(seq)==2 : ids.extend(range(int(seq[0]),int(seq[1])+1)) if len(seq)==2 : ids.extend(range(int(seq[0]),int(seq[1])+1))
else: ids.append(sid) else: ids.append(sid)
for sid in ids : for sid in ids :
key = impst.index.getById(str(sid)) key = impst.index.getById(str(sid))
if key !=None : if key !=None :
done = impst.getFile(key) done = impst.getFile(key)
if done : if done :
print('\n ',end='')
Clz.print(' == OK == ', Clz.bg2+Clz.fgb7)
print()
else:
print('\n ',end='') print('\n ',end='')
Clz.print(' == OK == ', Clz.bg2+Clz.fgb7) Clz.print(' == `' , Clz.bg1+Clz.fgB7, False)
Clz.print(str(sid) , Clz.bg1+Clz.fgB3, False)
Clz.print('` is not a valid id == ', Clz.bg1+Clz.fgB7)
print() print()
else:
print('\n ',end='')
Clz.print(' == `' , Clz.bg1+Clz.fgB7, False)
Clz.print(str(sid) , Clz.bg1+Clz.fgB3, False)
Clz.print('` is not a valid id == ', Clz.bg1+Clz.fgB7)
print()
elif a[0] == 'search': elif a[0] == 'search':
@ -333,80 +329,85 @@ class Cli:
account = conf.get('user','imap') account = conf.get('user','imap')
if not len(a)>1 : self.error_cmd('`'+a[0]+' need one argument',parser) if not len(a)>1 : self.error_cmd('`'+a[0]+' need one argument',parser)
vsearch = a[1] else :
matchIds = impst.index.getByPattern(vsearch) vsearch = a[1]
core.clear()
if matchIds is not None:
printLineSep(LINE_SEP_CHAR,LINE_SEP_LEN)
printHeaderTitle(APP_TITLE)
printHeaderPart('account',account)
printHeaderPart('index',uid)
printHeaderPart('box',impst.rootBox)
Clz.print(date, Clz.fgB7, True, True)
printLineSep(LINE_SEP_CHAR,LINE_SEP_LEN)
Clz.print(' searching --' , Clz.fgB3, False)
Clz.print(' `'+vsearch+'`' , Clz.fgB7, False)
Clz.print(' -- found ' , Clz.fgB3, False)
Clz.print(str(len(matchIds)), Clz.fgB1, False)
Clz.print(' results --' , Clz.fgB3)
printLineSep(LINE_SEP_CHAR,LINE_SEP_LEN)
matchIdsCatg = None matchIds = impst.index.getByPattern(vsearch)
matchIdsUser = None core.clear()
matchIdsCrit = None if matchIds is not None:
if o.category is not None : printLineSep(LINE_SEP_CHAR,LINE_SEP_LEN)
print(o.category) printHeaderTitle(APP_TITLE)
matchIdsCatg = impst.index.getByCategory(o.category) printHeaderPart('account',account)
if o.user is not None : printHeaderPart('index',uid)
matchIdsUser = impst.index.getByUser(o.user) printHeaderPart('box',impst.rootBox)
Clz.print(date, Clz.fgB7, True, True)
if o.category is not None : printLineSep(LINE_SEP_CHAR,LINE_SEP_LEN)
Clz.print(' searching --' , Clz.fgB3, False)
Clz.print(' `'+vsearch+'`' , Clz.fgB7, False)
Clz.print(' -- found ' , Clz.fgB3, False)
Clz.print(str(len(matchIds)), Clz.fgB1, False)
Clz.print(' results --' , Clz.fgB3)
printLineSep(LINE_SEP_CHAR,LINE_SEP_LEN)
matchIdsCatg = None
matchIdsUser = None
matchIdsCrit = None
if o.category is not None :
print(o.category)
matchIdsCatg = impst.index.getByCategory(o.category)
if o.user is not None : if o.user is not None :
matchIdsCrit = impst.index.getIntersection(matchIdsCatg,matchIdsUser) matchIdsUser = impst.index.getByUser(o.user)
else : matchIdsCrit = matchIdsCatg
if o.category is not None :
elif o.user is not None : if o.user is not None :
matchIdsCrit = matchIdsUser matchIdsCrit = impst.index.getIntersection(matchIdsCatg,matchIdsUser)
else : matchIdsCrit = matchIdsCatg
if matchIdsCrit is not None :
matchIds = impst.index.getIntersection(matchIds,matchIdsCrit) elif o.user is not None :
matchIdsCrit = matchIdsUser
order = o.order
if o.order_inv is not None: if matchIdsCrit is not None :
order = '-'+o.order_inv matchIds = impst.index.getIntersection(matchIds,matchIdsCrit)
impst.index.print(o.order,matchIds)
else: order = o.order
print('\n ',end='') if o.order_inv is not None:
Clz.print(' == no match found for pattern `', Clz.bg3+Clz.fgB4, False) order = '-'+o.order_inv
Clz.print(vsearch , Clz.bg3+Clz.fgB1, False) impst.index.print(o.order,matchIds)
Clz.print('` == ' , Clz.bg3+Clz.fgB4) else:
print() print('\n ',end='')
Clz.print(' == no match found for pattern `', Clz.bg3+Clz.fgB4, False)
Clz.print(vsearch , Clz.bg3+Clz.fgB1, False)
Clz.print('` == ' , Clz.bg3+Clz.fgB4)
print()
elif a[0] == 'remove': elif a[0] == 'remove':
if not len(a)>1 : self.error_cmd('`'+a[0]+' need one argument',parser) if not len(a)>1 : self.error_cmd('`'+a[0]+' need one argument',parser)
if not util.represents_int(a[1]): else :
print('\n ',end='')
Clz.print(' == `' , Clz.bg1+Clz.fgB7, False) if not util.represents_int(a[1]):
Clz.print(a[1] , Clz.bg1+Clz.fgB3, False)
Clz.print('` is not a valid id == ', Clz.bg1+Clz.fgB7)
print()
sys.exit(1)
vid = a[1]
key = impst.index.getById(vid)
if key !=None :
done = impst.removeFile(key)
if done :
print('\n ',end='') print('\n ',end='')
Clz.print(' == OK == ', Clz.bg2+Clz.fgb7) Clz.print(' == `' , Clz.bg1+Clz.fgB7, False)
Clz.print(a[1] , Clz.bg1+Clz.fgB3, False)
Clz.print('` is not a valid id == ', Clz.bg1+Clz.fgB7)
print() print()
else: self.exit(1)
print('\n ',end='') else :
Clz.print(' == `' , Clz.bg1+Clz.fgB7, False) vid = a[1]
Clz.print(a[1] , Clz.bg1+Clz.fgB3, False) key = impst.index.getById(vid)
Clz.print('` is not a valid id == ', Clz.bg1+Clz.fgB7) if key !=None :
print() done = impst.removeFile(key)
if done :
print('\n ',end='')
Clz.print(' == OK == ', Clz.bg2+Clz.fgb7)
print()
else:
print('\n ',end='')
Clz.print(' == `' , Clz.bg1+Clz.fgB7, False)
Clz.print(a[1] , Clz.bg1+Clz.fgB3, False)
Clz.print('` is not a valid id == ', Clz.bg1+Clz.fgB7)
print()
else : else :
self.error_cmd('unknow command `'+a[0]+'`',parser) self.error_cmd('unknow command `'+a[0]+'`',parser)
@ -414,8 +415,19 @@ class Cli:
def error_cmd(self,msg, parser): def error_cmd(self,msg, parser):
parser.error(msg) core.clear()
sys.exit(1) self.print_usage('')
Clz.print('error : '+msg,Clz.fgB7)
self.exit(1)
def parserError(self, msg):
core.clear()
self.print_usage('')
Clz.print('error : '+msg,Clz.fgB7)
self.exit(1)
def exit(self, code):
if Clz.isUnix : sys.exit(code)
def check_profile(self,profile, activeCheck=False): def check_profile(self,profile, activeCheck=False):
"""""" """"""
@ -427,7 +439,7 @@ class Cli:
conf = core.ImpraConf(self.ini,profile) conf = core.ImpraConf(self.ini,profile)
impst = None impst = None
try: try:
impst = core.ImpraStorage(conf) impst = core.ImpraStorage(conf, False, self.wkpath)
Clz.print(' done...', Clz.fgB2) Clz.print(' done...', Clz.fgB2)
except crypt.BadKeyException as e : except crypt.BadKeyException as e :
pass pass
@ -469,27 +481,30 @@ class Cli:
Clz.print(' USAGE :\n', Clz.fgB3) Clz.print(' USAGE :\n', Clz.fgB3)
Clz.print(' imprastorage ', Clz.fgb7, False) Clz.print(' imprastorage ', Clz.fgb7, False)
Clz.print('--help ', Clz.fgB3) if Clz.isUnix:
Clz.print('--help ', Clz.fgB3)
else:
Clz.print('help ', Clz.fgB3)
Clz.print(' imprastorage ', Clz.fgb7, False) Clz.print(' imprastorage ', Clz.fgb7, False)
Clz.print('add ', Clz.fgB3, False) Clz.print('add ', Clz.fgB3, False)
Clz.print('{', Clz.fgB1, False) Clz.print('{', Clz.fgB1, False)
Clz.print('filePath', Clz.fgb1, False) Clz.print('filePath', Clz.fgB1, False)
Clz.print('} ', Clz.fgB1, False) Clz.print('} ', Clz.fgB1, False)
Clz.print('[', Clz.fgB3, False) Clz.print('[', Clz.fgB3, False)
Clz.print('{', Clz.fgB1, False) Clz.print('{', Clz.fgB1, False)
Clz.print('name', Clz.fgb1, False) Clz.print('name', Clz.fgB1, False)
Clz.print('}', Clz.fgB1, False) Clz.print('}', Clz.fgB1, False)
Clz.print(' -c ', Clz.fgB3, False) Clz.print(' -c ', Clz.fgB3, False)
Clz.print('{', Clz.fgB1, False) Clz.print('{', Clz.fgB1, False)
Clz.print('category', Clz.fgb1, False) Clz.print('category', Clz.fgB1, False)
Clz.print('}', Clz.fgB1, False) Clz.print('}', Clz.fgB1, False)
Clz.print(']', Clz.fgB3) Clz.print(']', Clz.fgB3)
Clz.print(' imprastorage ', Clz.fgb7, False) Clz.print(' imprastorage ', Clz.fgb7, False)
Clz.print('get ', Clz.fgB3, False) Clz.print('get ', Clz.fgB3, False)
Clz.print('{', Clz.fgB1, False) Clz.print('{', Clz.fgB1, False)
Clz.print('id|ids', Clz.fgb1, False) Clz.print('id|ids', Clz.fgB1, False)
Clz.print('}', Clz.fgB1) Clz.print('}', Clz.fgB1)
Clz.print(' imprastorage ', Clz.fgb7, False) Clz.print(' imprastorage ', Clz.fgb7, False)
@ -497,45 +512,45 @@ class Cli:
Clz.print('[', Clz.fgB3, False) Clz.print('[', Clz.fgB3, False)
Clz.print(' -c ', Clz.fgB3, False) Clz.print(' -c ', Clz.fgB3, False)
Clz.print('{', Clz.fgB1, False) Clz.print('{', Clz.fgB1, False)
Clz.print('category', Clz.fgb1, False) Clz.print('category', Clz.fgB1, False)
Clz.print('}', Clz.fgB1, False) Clz.print('}', Clz.fgB1, False)
Clz.print(' -u ', Clz.fgB3, False) Clz.print(' -u ', Clz.fgB3, False)
Clz.print('{', Clz.fgB1, False) Clz.print('{', Clz.fgB1, False)
Clz.print('user', Clz.fgb1, False) Clz.print('user', Clz.fgB1, False)
Clz.print('}', Clz.fgB1, False) Clz.print('}', Clz.fgB1, False)
Clz.print(' -o', Clz.fgB3, False) Clz.print(' -o', Clz.fgB3, False)
Clz.print('|', Clz.fgB1, False) Clz.print('|', Clz.fgB1, False)
Clz.print('-O ', Clz.fgB3, False) Clz.print('-O ', Clz.fgB3, False)
Clz.print('{', Clz.fgB1, False) Clz.print('{', Clz.fgB1, False)
Clz.print('colon', Clz.fgb1, False) Clz.print('colon', Clz.fgB1, False)
Clz.print('}', Clz.fgB1, False) Clz.print('}', Clz.fgB1, False)
Clz.print(']', Clz.fgB3) Clz.print(']', Clz.fgB3)
Clz.print(' imprastorage ', Clz.fgb7, False) Clz.print(' imprastorage ', Clz.fgb7, False)
Clz.print('remove ', Clz.fgB3, False) Clz.print('remove ', Clz.fgB3, False)
Clz.print('{', Clz.fgB1, False) Clz.print('{', Clz.fgB1, False)
Clz.print('id', Clz.fgb1, False) Clz.print('id', Clz.fgB1, False)
Clz.print('}', Clz.fgB1) Clz.print('}', Clz.fgB1)
Clz.print(' imprastorage ', Clz.fgb7, False) Clz.print(' imprastorage ', Clz.fgb7, False)
Clz.print('search ', Clz.fgB3, False) Clz.print('search ', Clz.fgB3, False)
Clz.print('{', Clz.fgB1, False) Clz.print('{', Clz.fgB1, False)
Clz.print('pattern', Clz.fgb1, False) Clz.print('pattern', Clz.fgB1, False)
Clz.print('} ', Clz.fgB1, False) Clz.print('} ', Clz.fgB1, False)
Clz.print('[', Clz.fgB3, False) Clz.print('[', Clz.fgB3, False)
Clz.print(' -c ', Clz.fgB3, False) Clz.print(' -c ', Clz.fgB3, False)
Clz.print('{', Clz.fgB1, False) Clz.print('{', Clz.fgB1, False)
Clz.print('category', Clz.fgb1, False) Clz.print('category', Clz.fgB1, False)
Clz.print('}', Clz.fgB1, False) Clz.print('}', Clz.fgB1, False)
Clz.print(' -u ', Clz.fgB3, False) Clz.print(' -u ', Clz.fgB3, False)
Clz.print('{', Clz.fgB1, False) Clz.print('{', Clz.fgB1, False)
Clz.print('user', Clz.fgb1, False) Clz.print('user', Clz.fgB1, False)
Clz.print('}', Clz.fgB1, False) Clz.print('}', Clz.fgB1, False)
Clz.print(' -o', Clz.fgB3, False) Clz.print(' -o', Clz.fgB3, False)
Clz.print('|', Clz.fgB1, False) Clz.print('|', Clz.fgB1, False)
Clz.print('-O ', Clz.fgB3, False) Clz.print('-O ', Clz.fgB3, False)
Clz.print('{', Clz.fgB1, False) Clz.print('{', Clz.fgB1, False)
Clz.print('colon', Clz.fgb1, False) Clz.print('colon', Clz.fgB1, False)
Clz.print('}', Clz.fgB1, False) Clz.print('}', Clz.fgB1, False)
Clz.print(']', Clz.fgB3) Clz.print(']', Clz.fgB3)
@ -545,14 +560,14 @@ class Cli:
Clz.print('|', Clz.fgB1, False) Clz.print('|', Clz.fgB1, False)
Clz.print('-V ', Clz.fgB3, False) Clz.print('-V ', Clz.fgB3, False)
Clz.print('{', Clz.fgB1, False) Clz.print('{', Clz.fgB1, False)
Clz.print('profile', Clz.fgb1, False) Clz.print('profile', Clz.fgB1, False)
Clz.print('}', Clz.fgB1) Clz.print('}', Clz.fgB1)
Clz.print(' imprastorage ', Clz.fgb7, False) Clz.print(' imprastorage ', Clz.fgb7, False)
Clz.print('conf', Clz.fgB3, False) Clz.print('conf', Clz.fgB3, False)
Clz.print(' -S ', Clz.fgB3, False) Clz.print(' -S ', Clz.fgB3, False)
Clz.print('{', Clz.fgB1, False) Clz.print('{', Clz.fgB1, False)
Clz.print('profile', Clz.fgb1, False) Clz.print('profile', Clz.fgB1, False)
Clz.print('} ', Clz.fgB1, False) Clz.print('} ', Clz.fgB1, False)
Clz.print('[', Clz.fgB3, False) Clz.print('[', Clz.fgB3, False)
Clz.print(' -K', Clz.fgB3, False) Clz.print(' -K', Clz.fgB3, False)
@ -592,8 +607,6 @@ class Cli:
Clz.print(' '*50+'don\'t print status messages to stdout' , Clz.fgB7) Clz.print(' '*50+'don\'t print status messages to stdout' , Clz.fgB7)
Clz.print(' '*4+'-d, --debug' , Clz.fgB3) Clz.print(' '*4+'-d, --debug' , Clz.fgB3)
Clz.print(' '*50+'set debug mode' , Clz.fgB7) Clz.print(' '*50+'set debug mode' , Clz.fgB7)
Clz.print(' '*4+'-v, --version' , Clz.fgB3)
Clz.print(' '*50+'show program\'s version number' , Clz.fgB7)
print('\n') print('\n')
Clz.print(' COMMANDS OPTIONS :\n' , Clz.fgB3) Clz.print(' COMMANDS OPTIONS :\n' , Clz.fgB3)
@ -692,7 +705,7 @@ class Cli:
"""""" """"""
self.print_header() self.print_header()
Clz.print(APP_DESC, Clz.fgN1) Clz.print(APP_DESC, Clz.fgN1)
self.print_usage('', True) self.print_usage('',True)
self.print_options() self.print_options()
printLineSep(LINE_SEP_CHAR,LINE_SEP_LEN) printLineSep(LINE_SEP_CHAR,LINE_SEP_LEN)
print() print()

View File

@ -630,7 +630,7 @@ class ImpraStorage:
print() print()
Clz.print(' file : ' , Clz.fgn7, False) Clz.print(' file : ' , Clz.fgn7, False)
Clz.print(path , Clz.fgN1) Clz.print(path , Clz.fgN1)
Clz.print(' md5sum : ' , Clz.fgn7, False) Clz.print(' hash : ' , Clz.fgn7, False)
Clz.print(md5 , Clz.fgN2) Clz.print(md5 , Clz.fgN2)
print() print()
if not self.index.get(md5) : if not self.index.get(md5) :

0
impra/imap.py Executable file → Normal file
View File

3
impra/util.py Executable file → Normal file
View File

@ -51,7 +51,6 @@ DEBUG_INFO = 3
DEBUG = True DEBUG = True
DEBUG_LEVEL = DEBUG_INFO DEBUG_LEVEL = DEBUG_INFO
COLOR_MODE = True COLOR_MODE = True
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -447,7 +446,7 @@ class Coloriz:
# normal eq bold # normal eq bold
exec('self._wn%i = self._wf%i' % (i,i)) exec('self._wn%i = self._wf%i' % (i,i))
# normal high intensity eq bold high intensity # normal high intensity eq bold high intensity
exec('self._wN%i = self._wB%i' % (i,i)) exec('self._wN%i = self._wF%i' % (i,i))
j += 1 j += 1
if not self.isUnix : if not self.isUnix :

14
imprastorage.py Executable file → Normal file
View File

@ -26,8 +26,8 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with ImpraStorage. If not, see <http://www.gnu.org/licenses/>. # along with ImpraStorage. If not, see <http://www.gnu.org/licenses/>.
from impra.core import ImpraConf, ImpraStorage from impra.core import ImpraConf, ImpraStorage, realpath, dirname, abspath, sep
from impra.util import IniFile, RuTime, get_file_path from impra.util import IniFile, RuTime, get_file_path, Clz
from impra.cli import Cli from impra.cli import Cli
import sys, os import sys, os
@ -38,6 +38,14 @@ import sys, os
if __name__ == '__main__': if __name__ == '__main__':
Cli(get_file_path(__file__ )) if not Clz.isUnix:
if len(sys.argv)>1 and sys.argv[1] == '--run' :
Cli.print_header(None)
os.system(realpath('./cmd.bat'))
elif len(sys.argv)==1 :
os.system(realpath('./launcher.bat'))
else: Cli(realpath('./')+sep)
else :
Cli(get_file_path(realpath('./')+sep))
#python -O -m compileall impra/*.py #python -O -m compileall impra/*.py

View File

@ -1,60 +1,22 @@
@Echo Off @Echo Off
:: This first title is used to store the registry setting Set _Title=ImpraStorage
:: You can use it for the title of the First window, or change
:: The Title of both windows after opening
Set _Title=ImpraStorage
:: Set Height in lines, Width in characters. Buffer width is set
:: to the same value as the window width
Set _Height=60 Set _Height=60
Set _Width=122 Set _Width=122
Set _BHeight=5000 Set _BHeight=5000
Set _BWidth=%_Width% Set _BWidth=%_Width%
:: Set position of the Top left corner in pixels
:: Position is relative to the Top left corner of the screen
Set _xPos=0 Set _xPos=0
Set _yPos=0 Set _yPos=0
:: Color values are the same as for the Color command
Set _Color=1E Set _Color=1E
:: Calculate hex values needed in the registry
Set /A _BufferSize=_BHeight*0x10000+_BWidth Set /A _BufferSize=_BHeight*0x10000+_BWidth
Set /A _WindowPos=_yPos*0x10000+_xPos Set /A _WindowPos=_yPos*0x10000+_xPos
Set /A _WindowSize=_Height*0x10000+_Width Set /A _WindowSize=_Height*0x10000+_Width
:: This command will be passed to the Prompt to change the Title and Prompt Set _Cmd=Title ^&Prompt ^&Color 0F^&ImpraStorage.exe --run
:: The ampersand must be escaped
:: Set _Cmd=Title Send^&Prompt $T$G
:: Call :_OpenCP %_BufferSize% %_Color% %_WindowPos% %_WindowSize% "%_Title%" "%_CMD%"
:: Increase the _yPos value so 2nd window is below the first.
:: 12 is the height in pixels for the font being used.
:: 40 is a value to allow for the height of the Title Bar. Adjust as needed
::Set /A _yPos=_yPos+_Height*12+40
::Set /A _WindowPos=_yPos*0x10000+_xPos
:: 0 = Black 8 = Gray
:: 1 = Blue 9 = Light Blue
:: 2 = Green A = Light Green
:: 3 = Aqua B = Light Aqua
:: 4 = Red C = Light Red
:: 5 = Purple D = Light Purple
:: 6 = Yellow E = Light Yellow
:: 7 = White F = Bright White
:: This command will be passed to the Prompt to change the Title, Prompt, and Color
Set _Cmd=Title ImpraStorage^&Prompt $T$G^&Color 0F
Call :_OpenCP %_BufferSize% %_Color% %_WindowPos% %_WindowSize% "%_Title%" "%_CMD%" Call :_OpenCP %_BufferSize% %_Color% %_WindowPos% %_WindowSize% "%_Title%" "%_CMD%"
Goto :EOF Goto :EOF
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Subroutines
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:_OpenCP :_OpenCP
Reg Add "HKCU\Console\%~5" /V ScreenBufferSize /T REG_DWORD /D %1 /F Reg Add "HKCU\Console\%~5" /V ScreenBufferSize /T REG_DWORD /D %1 /F
Reg Add "HKCU\Console\%~5" /V ScreenColors /T REG_DWORD /D 0x%2 /F Reg Add "HKCU\Console\%~5" /V ScreenColors /T REG_DWORD /D 0x%2 /F
Reg Add "HKCU\Console\%~5" /V WindowPosition /T REG_DWORD /D %3 /F Reg Add "HKCU\Console\%~5" /V WindowPosition /T REG_DWORD /D %3 /F
Reg Add "HKCU\Console\%~5" /V WindowSize /T REG_DWORD /D %4 /F Reg Add "HKCU\Console\%~5" /V WindowSize /T REG_DWORD /D %4 /F
Start "%~5" %COMSPEC% /K %6 Start "%~5" %COMSPEC% /K %6
:: Only one single command line is needed to receive user input exit
FOR /F "tokens=*" %%A IN ('TYPE CON') DO SET INPUT=%%A
:: Use quotes if you want to display redirection characters as well
ECHO You typed: "%INPUT%"

View File

@ -4,7 +4,10 @@ from cx_Freeze import setup, Executable
productName = "ImpraStorage" productName = "ImpraStorage"
# Dependencies are automatically detected, but it might need fine tuning. # Dependencies are automatically detected, but it might need fine tuning.
build_exe_options = {"packages": ["os","subprocess","importlib","platform"], "excludes": ["tkinter"]} build_exe_options = {"packages": ["os","subprocess","importlib","platform"],
"excludes": ["tkinter"],
"include_files": [('launcher.bat','launcher.bat'),('cmd.bat','cmd.bat'),('wk','wk')]
}
# GUI applications require a different base on Windows (the default is for a # GUI applications require a different base on Windows (the default is for a
# console application). # console application).
@ -18,31 +21,29 @@ base = None
if 'bdist_msi' in sys.argv: if 'bdist_msi' in sys.argv:
sys.argv += ['--initial-target-dir', 'C:\InstallDir\\' + productName] sys.argv += ['--initial-target-dir', 'C:\\' + productName]
sys.argv += ['--install-script', 'install.py'] # sys.argv += ['--install-script', 'install.py']
exe = Executable( exe = Executable(
script="imprastorage.py", script="imprastorage.py",
base=None, base=None,
targetName="ImpraStorage.exe", targetName="imprastorage.exe"
targetDir="lib",
shortcutName="ImpraStorage",
) )
setup( setup(
name="ImpraStorage.exe", name="ImpraStorage.exe",
version="0.6", version="0.6",
author="a-Sansara", author="a-Sansara",
description="ImpraStorage provided a private imap access to store large files. License GNU GPLv3 Copyright 2012 pluie.org", description="ImpraStorage provided a private imap access to store large files. License GNU GPLv3 Copyright 2012 pluie.org",
executables=[exe], executables=[exe],
include-files=('./launcher.bat','./launcher.bat') options = {"build_exe": build_exe_options},
scripts=[ scripts=[
'install.py'
] ]
) )
else : else :
setup( name = "ImpraStorage", setup( name = "ImpraStorage",
version = "0.5", version = "0.5",
description = "mpraStorage provided a private imap access to store large files", description = "ImpraStorage provided a private imap access to store large files",
options = {"build_exe": build_exe_options}, options = {"build_exe": build_exe_options},
executables = [Executable("imprastorage.py", base=base)]) executables = [Executable("imprastorage.py", base=base)])