diff --git a/impra/cli.py b/impra/cli.py index efe1573..400e456 100644 --- a/impra/cli.py +++ b/impra/cli.py @@ -34,15 +34,18 @@ import sys, os, platform import impra.crypt as crypt import impra.util as util import impra.core as core -from impra.util import C +from impra.util import Clz -LINE_SEP = C.IBLACK+'โ€•'*120+C.OFF -APP_TITLE = 'ImpraStorage' -APP_VERSION = '0.5' -APP_AUTHOR = 'a-Sansara' -APP_COPY = 'pluie.org' -APP_LICENSE = 'GNU GPLv3' -APP_DESC = """ + +LINE_SEP_LEN = 120 +LINE_SEP_CHAR = 'โ€•' +if not Clz.isUnix : LINE_SEP_CHAR = '-' +APP_TITLE = 'ImpraStorage' +APP_VERSION = '0.5' +APP_AUTHOR = 'a-Sansara' +APP_COPY = 'pluie.org' +APP_LICENSE = 'GNU GPLv3' +APP_DESC = """ ImpraStorage provided a private imap access to store large files. Each file stored on the server is split in severals random parts. Each part also contains random noise data (lenght depends on a crypt key) @@ -61,6 +64,22 @@ ImpraStorage randomly upload each parts then update the index. """ +def printLineSep(sep,lenSep): + """""" + Clz.print(sep*lenSep, Clz.fgB0) +def printHeaderTitle(title): + """""" + Clz.print(' -- %s -- ' % title, Clz.BG4+Clz.fgB7, False, True) + +def printHeaderPart(label,value): + """""" + Clz.print(' [' , Clz.fgB0, False) + Clz.print(label, Clz.fgB3, False) + Clz.print(':' , Clz.fgB0, False) + Clz.print(value, Clz.fgB4, False) + Clz.print('] ' , Clz.fgB0, False) + + class _OptionParser(OptionParser): """A simplified OptionParser""" @@ -251,13 +270,15 @@ you can remove index but all presents files on the box %s will be unrecoverable noData = impst.index.isEmpty() if uid == None or noData : uid = 'EMPTY' if date == None or noData : date = '' - impst.index.print('\ -'+LINE_SEP+'\n\ -%s -- %s -- %s ' % (C.ON_IBLUE+C.BWHITE , APP_TITLE , C.OFF+C.BYELLOW)+'\ - %s[%saccount%s:%s%s%s]%s ' % (C.BIBLACK,C.BYELLOW,C.BIBLACK,C.BBLUE, account , C.BIBLACK, C.BYELLOW)+'\ - %s[%sindex%s:%s%s%s]%s ' % (C.BIBLACK,C.BYELLOW,C.BIBLACK,C.BBLUE, uid , C.BIBLACK, C.BYELLOW)+'\ - %s[%sbox%s:%s%s%s]%s ' % (C.BIBLACK,C.BYELLOW,C.BIBLACK,C.BBLUE, impst.rootBox , C.BIBLACK, C.BYELLOW)+'\ - %s%s%s ' % (C.BWHITE , date , C.OFF+C.BYELLOW)+'\n'+LINE_SEP) + core.clear() + 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) + impst.index.print() status, resp = impst.ih.srv.search(None, '(SUBJECT "%s")' % '584d15abeb71fbd92fa5861970088b32ebb1d2d6650cec6115a28b64877d70f2') ids = [m for m in resp[0].split()] diff --git a/impra/core.py b/impra/core.py index 6b77f77..c27bd7a 100644 --- a/impra/core.py +++ b/impra/core.py @@ -46,10 +46,9 @@ from os.path import abspath, dirname, join, realpath, basename, get from re import split as regsplit, match as regmatch, compile as regcompile, search as regsearch from time import time from impra.imap import ImapHelper, ImapConfig -from impra.util import __CALLER__, RuTime, formatBytes, randomFrom, bstr, quote_escape, stack, run, file_exists, get_file_content, DEBUG, DEBUG_ALL, DEBUG_LEVEL, DEBUG_NOTICE, DEBUG_WARN, mkdir_p, is_binary, C, clear +from impra.util import __CALLER__, RuTime, formatBytes, randomFrom, bstr, quote_escape, stack, run, file_exists, get_file_content, DEBUG, DEBUG_ALL, DEBUG_LEVEL, DEBUG_NOTICE, DEBUG_WARN, mkdir_p, is_binary, clear, Clz from impra.crypt import Kirmah, ConfigKey, Noiser, Randomiz, hash_sha256, hash_md5_file, BadKeyException -LINE_SEP = C.IBLACK+'โ€•'*120+C.OFF # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~ class FSplitter ~~ @@ -393,43 +392,34 @@ class ImpraIndex: def print(self,header='', matchIds=None): """Print index content as formated bloc""" - data = self.toString(matchIds).split(self.SEP_ITEM) - clear() - print(header) - print(C.ON_IBLACK+' \ -%s%s%s' % (C.BYELLOW,'ID' ,' '*1 )+'\ -%s%s%s' % (C.BYELLOW,'HASH' ,' '*15)+'\ -%s%s%s' % (C.BYELLOW,'LABEL' ,' '*38)+'\ -%s%s%s' % (C.BYELLOW,'PART' ,' '*2 )+'\ -%s%s%s' % (C.BYELLOW,'TYPE' ,' '*2 )+'\ -%s%s%s' % (C.BYELLOW,'OWNER' ,' '*12)+'\ -%s%s%s' % (C.BYELLOW,'CATEGORY',' '*17)+C.OFF+'\n'+LINE_SEP) - for row in data: - if row.rstrip('\n') != '': print(row) - print(LINE_SEP) - - def toString(self,matchIds): - """Make a string representation of the index as it was store on the server""" + #clear() + if header is not '':print(header) + from impra.cli import printLineSep, LINE_SEP_LEN, LINE_SEP_CHAR + #printLineSep(LINE_SEP_CHAR,LINE_SEP_LEN) + Clz.print(' ID'+' '*1, Clz.BG4+Clz.fgB7, False, False) + print('HASH' +' '*15, end='') + print('LABEL' +' '*38, end='') + print('PART' +' '*2 , end='') + print('TYPE' +' '*2 , end='') + print('OWNER' +' '*12, end='') + Clz.print('CATEGORY'+' '*17, Clz.BG4+Clz.fgB7) + printLineSep(LINE_SEP_CHAR,LINE_SEP_LEN) data = '' r = [k for i, k in enumerate(self.dic) if not k.startswith(self.SEP_KEY_INTERN)] for k in r : v = self.dic.get(k) k = k.lstrip('\n\r') - if not k[0]==self.SEP_KEY_INTERN and len(k)>1: if matchIds==None or v[self.UID] in matchIds: - data += '%s%s%s' % (C.BIRED , str(v[self.UID]).rjust(1+ceil(len(str(v[self.UID]))/10),' '), ' '*2) - data += '%s%s%s' % (C.IGREEN , str(k)[0:12]+'... ' , ' '*2) - data += '%s%s%s' % (C.BWHITE , str(v[self.LABEL]).ljust(42,' ') , ' '*2) - data += '%s%s%s' % (C.BPURPLE , str(v[self.PARTS]).rjust(2 ,'0') , ' '*2) - data += '%s%s%s' % (C.BIGREEN , str(v[self.EXT]).ljust(5,' ') , ' '*2) - data += '%s%s%s' % (C.BWHITE , self.getUser(str(v[self.OWNER])).ljust(15,' ') , ' '*2) - data += '%s%s%s' % (C.BBLUE , str(v[self.CATG]) , ' '*2) + Clz.print(str(v[self.UID]).rjust(1+ceil(len(str(v[self.UID]))/10),' ') +' '*2, Clz.fgB1, False) + Clz.print(str(k)[0:12]+'... ' +' '*2, Clz.fgn2, False) + Clz.print(str(v[self.LABEL]).ljust(42,' ') +' '*2, Clz.fgB7, False) + Clz.print(str(v[self.PARTS]).rjust(2 ,'0') +' '*2, Clz.fgB5, False) + Clz.print(str(v[self.EXT]).ljust(5,' ') +' '*2, Clz.fgB4, False) + Clz.print(self.getUser(str(v[self.OWNER])).ljust(15,' ') +' '*2, Clz.fgB7, False) + Clz.print(str(v[self.CATG]) +' '*2, Clz.fgB4) - #~ elif len(k)>1: - #~ print(k,'=',v) - data = data+self.SEP_ITEM - return data; + printLineSep(LINE_SEP_CHAR,LINE_SEP_LEN) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/impra/util.py b/impra/util.py index cc9aa79..8db85eb 100755 --- a/impra/util.py +++ b/impra/util.py @@ -37,9 +37,9 @@ from math import log, floor, ceil from os import urandom, popen, sep, makedirs, system from os.path import dirname, realpath, abspath, join from random import choice -from re import split as regsplit +from re import split as regsplit, search as regsearch, finditer as regfinditer from subprocess import PIPE, Popen -from sys import stderr, executable as pyexec +from sys import stderr, executable as pyexec, stdout import platform #~ from sys.stdout import isatty from time import time @@ -213,8 +213,11 @@ class RuTime: def _start(self): - global C - if self.debug :print(C.BRED+' ==> '+C.BYELLOW+self._paramize(self.label)+C.OFF) + global Clz + if self.debug : + Clz.print(' ==> ', Clz.fgb1, False) + self._paramize(self.label) + Clz.print('', Clz.OFF) self.sc = time() def stop(self): @@ -223,14 +226,21 @@ class RuTime: if self.debug: self._stats() def _paramize(self,data): - global C - s = data.replace('(','('+C.GREEN) - s = s.replace(')',C.BYELLOW+')'+C.OFF) - return s + global Clz + sp = [m.start() for m in regfinditer('\(', data)] + ep = [m.start() for m in regfinditer('\)', data)] + if len(sp) > 0 : + Clz.print(data[:sp[0]+1], Clz.fgb3, False) + Clz.print(data[sp[0]+1:ep[0]], Clz.fgn2, False) + Clz.print(data[ep[0]:], Clz.fgb3, False) + else: + Clz.print(data, Clz.fgb3, False, True) def _stats(self): - global C - print(C.BRED+' <== '+C.BYELLOW+self._paramize(self.label)+(' %s%.5f s%s' % (C.WHITE,self.ec-self.sc,C.OFF))) + global Clz + Clz.print(' <== ', Clz.fgb1, False) + self._paramize(self.label) + Clz.print('%.5f' % (self.ec-self.sc), Clz.fgn7) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -350,83 +360,98 @@ class StrIterator: class Coloriz: - # Reset - OFF ='\033[1;m' - - # Regular Colors - BLACK ='\033[0;30m' - RED ='\033[0;31m' - GREEN ='\033[0;32m' - YELLOW ='\033[0;33m' - BLUE ='\033[0;34m' - PURPLE ='\033[0;35m' - CYAN ='\033[0;36m' - WHITE ='\033[0;37m' - - # Bold - BBLACK ='\033[1;30m' - BRED ='\033[1;31m' - BGREEN ='\033[1;32m' - BYELLOW ='\033[1;33m' - BBLUE ='\033[1;34m' - BPURPLE ='\033[1;35m' - BCYAN ='\033[1;36m' - BWHITE ='\033[1;37m' - - # Underline - UBLACK ='\033[4;30m' - URED ='\033[4;31m' - UGREEN ='\033[4;32m' - UYELLOW ='\033[4;33m' - UBLUE ='\033[4;34m' - UPURPLE ='\033[4;35m' - UCYAN ='\033[4;36m' - UWHITE ='\033[4;37m' - - # Background - ON_BLACK ='\033[40m' - ON_RED ='\033[41m' - ON_GREEN ='\033[42m' - ON_YELLOW ='\033[43m' - ON_BLUE ='\033[44m' - ON_PURPLE ='\033[45m' - ON_CYAN ='\033[46m' - ON_WHITE ='\033[47m' - - # High Intensity - IBLACK ='\033[0;90m' - IRED ='\033[0;91m' - IGREEN ='\033[0;92m' - IYELLOW ='\033[0;93m' - IBLUE ='\033[0;94m' - IPURPLE ='\033[0;95m' - ICYAN ='\033[0;96m' - IWHITE ='\033[0;97m' - - # Bold High Intensity - BIBLACK ='\033[1;90m' - BIRED ='\033[1;91m' - BIGREEN ='\033[1;92m' - BIYELLOW ='\033[1;93m' - BIBLUE ='\033[1;94m' - BIPURPLE ='\033[1;95m' - BICYAN ='\033[1;96m' - BIWHITE ='\033[1;97m' - - # High Intensity backgrounds - ON_IBLACK ='\033[0;100m' - ON_IRED ='\033[0;101m' - ON_IGREEN ='\033[0;102m' - ON_IYELLOW ='\033[0;103m' - ON_IBLUE ='\033[0;104m' - ON_IPURPLE ='\033[10;95m' - ON_ICYAN ='\033[0;106m' - ON_IWHITE ='\033[0;107m' + _MARKER = '!ยง' + """""" + _SEP = ';' + """""" + _PATTERN_COLOR = '^'+_MARKER[0]+'[nfNFbB][0-7]'+_SEP+'$' + """""" + _wFH = 0x0008 + """""" + _wBH = 0x0080 + """""" + _uOFF = '\033[1;m' + """""" + _wOFF = None + """""" + _LF = '\n' + """""" + OFF = _MARKER+_MARKER[0]+'OFF'+_SEP+_MARKER + """""" + isUnix = platform.system() != 'Windows' + """""" def __init__(self): - """""" - global COLOR_MODE - if not COLOR_MODE : - self.OFF = self.BLACK = self.RED = self.GREEN = self.YELLOW = self.BLUE = self.PURPLE = self.CYAN = self.WHITE = self.BBLACK = self.BRED = self.BGREEN = self.BYELLOW = self.BBLUE = self.BPURPLE = self.BCYAN = self.BWHITE = self.UBLACK = self.URED = self.UGREEN = self.UYELLOW = self.UBLUE = self.UPURPLE = self.UCYAN = self.UWHITE = self.ON_BLACK = self.ON_RED = self.ON_GREEN = self.ON_YELLOW = self.ON_BLUE = self.ON_PURPLE = self.ON_CYAN = self.ON_WHITE = self.IBLACK = self.IRED = self.IGREEN = self.IYELLOW = self.IBLUE = self.IPURPLE = self.ICYAN = self.IWHITE = self.BIBLACK = self.BIRED = self.BIGREEN = self.BIYELLOW = self.BIBLUE = self.BIPURPLE = self.BICYAN = self.BIWHITE = self.ON_IBLACK = self.ON_IRED = self.ON_IGREEN = self.ON_IYELLOW = self.ON_IBLUE = self.ON_IPURPLE = self.ON_ICYAN = self.ON_IWHITE = '' + """Colors for both plateform are : 0: black - 1: red - 2:green - 3: yellow - 4: blue - 5: purple - 6: cyan - 7: white + available class members : + foreground normal (same as bold for w32): + self.fgn0 -> self.fgn7 + foreground bold : + self.fgb0 -> self.fgb7 + foreground high intensity (same as bold high intensity for w35): + self.fgN0 -> self.fgN7 + foreground bold high intensity : + self.fgB0 -> self.fgB7 + background + self.bg0 -> self.bg7 + background high intensity + self.BG0 -> self.BG7 + default colors : + self.OFF + + usage : + pc = PColor() + pc.print('%smon label%s:%sma value%s' % (pc.BG4+pc.fgN7, pc.OFF+pc.fgn1, pc.fgb4, pc.OFF)) + """ + if not self.isUnix: + j = 0 + for i in (0,4,2,6,1,5,3,7): + exec('self._wf%i = 0x000%i' % (i,j) + '\nself._wb%i = 0x00%i0' % (i,j) + '\nself._wF%i = 0x000%i | self._wFH' % (i,j) + '\nself._wB%i = 0x00%i0 | self._wBH' % (i,j)) + # normal eq bold + exec('self._wn%i = self._wf%i' % (i,i)) + # normal high intensity eq bold high intensity + exec('self._wN%i = self._wB%i' % (i,i)) + j += 1 + + if not self.isUnix : + import impra.w32color as w32cons + self._wOFF = w32cons.get_text_attr() + self._wOFFbg = self._wOFF & 0x0070 + self._wOFFfg = self._wOFF & 0x0007 + self.setColor = w32cons.set_text_attr -C = Coloriz() + for i in range(0,8): + # foreground normal + exec('self.fgn%i = self._MARKER + self._MARKER[0] + "n%i" + self._SEP + self._MARKER' % (i,i)) + if True or isUnix : exec('self._un%i = "\\033[0;3%im"' % (i,i)) + # foreground bold + exec('self.fgb%i = self._MARKER + self._MARKER[0] + "f%i" + self._SEP + self._MARKER' % (i,i)) + if True or isUnix : exec('self._uf%i = "\\033[1;3%im"' % (i,i)) + # foreground high intensity + exec('self.fgN%i = self._MARKER + self._MARKER[0] + "N%i" + self._SEP + self._MARKER' % (i,i)) + if True or isUnix : exec('self._uN%i = "\\033[0;9%im"' % (i,i)) + # foreground bold high intensity + exec('self.fgB%i = self._MARKER + self._MARKER[0] + "F%i" + self._SEP + self._MARKER' % (i,i)) + if True or isUnix : exec('self._uF%i = "\\033[1;9%im"' % (i,i)) + # background + exec('self.bg%i = self._MARKER + self._MARKER[0] + "b%i" + self._SEP + self._MARKER' % (i,i)) + if True or isUnix : exec('self._ub%i = "\\033[4%im"' % (i,i)) + # background high intensity + exec('self.BG%i = self._MARKER + self._MARKER[0] + "B%i" + self._SEP + self._MARKER' % (i,i)) + if True or isUnix : exec('self._uB%i = "\\033[0;10%im"' % (i,i)) + + def print(self,data,colors,endLF=True,endClz=True): + """""" + if not endLF : ev = '' + else: ev = self._LF + tokens = [c.lstrip(self._MARKER[0]).rstrip(self._SEP) for c in colors.split(self._MARKER) if c is not ''] + if self.isUnix : + if endClz : data += self._uOFF + print(eval('self._u'+'+self._u'.join(tokens))+data,end=ev) + else : + self.setColor(eval('self._w'+'|self._w'.join(tokens))) + print(data,end=ev) + stdout.flush() + if endClz : self.setColor(self._wOFF) + +Clz = Coloriz() diff --git a/impra/w32color.py b/impra/w32color.py new file mode 100644 index 0000000..474e8b5 --- /dev/null +++ b/impra/w32color.py @@ -0,0 +1,75 @@ +""" +Colors text in console mode application (win32). +Uses ctypes and Win32 methods SetConsoleTextAttribute and +GetConsoleScreenBufferInfo. + +$Id: color_console.py 534 2009-05-10 04:00:59Z andre $ +""" + +from ctypes import windll, Structure, c_short as SHORT, c_ushort as WORD, byref + +class COORD(Structure): + """struct in wincon.h.""" + _fields_ = [ + ("X", SHORT), + ("Y", SHORT)] + +class SMALL_RECT(Structure): + """struct in wincon.h.""" + _fields_ = [ + ("Left", SHORT), + ("Top", SHORT), + ("Right", SHORT), + ("Bottom", SHORT)] + +class CONSOLE_SCREEN_BUFFER_INFO(Structure): + """struct in wincon.h.""" + _fields_ = [ + ("dwSize", COORD), + ("dwCursorPosition", COORD), + ("wAttributes", WORD), + ("srWindow", SMALL_RECT), + ("dwMaximumWindowSize", COORD)] + +# winbase.h +STD_INPUT_HANDLE = -10 +STD_OUTPUT_HANDLE = -11 +STD_ERROR_HANDLE = -12 + +# wincon.h +FOREGROUND_BLACK = 0x0000 +FOREGROUND_BLUE = 0x0001 +FOREGROUND_GREEN = 0x0002 +FOREGROUND_CYAN = 0x0003 +FOREGROUND_RED = 0x0004 +FOREGROUND_MAGENTA = 0x0005 +FOREGROUND_YELLOW = 0x0006 +FOREGROUND_GREY = 0x0007 +FOREGROUND_INTENSITY = 0x0008 # foreground color is intensified. + +BACKGROUND_BLACK = 0x0000 +BACKGROUND_BLUE = 0x0010 +BACKGROUND_GREEN = 0x0020 +BACKGROUND_CYAN = 0x0030 +BACKGROUND_RED = 0x0040 +BACKGROUND_MAGENTA = 0x0050 +BACKGROUND_YELLOW = 0x0060 +BACKGROUND_GREY = 0x0070 +BACKGROUND_INTENSITY = 0x0080 # background color is intensified. + +stdout_handle = windll.kernel32.GetStdHandle(STD_OUTPUT_HANDLE) +SetConsoleTextAttribute = windll.kernel32.SetConsoleTextAttribute +GetConsoleScreenBufferInfo = windll.kernel32.GetConsoleScreenBufferInfo + +def get_text_attr(): + """Returns the character attributes (colors) of the console screen + buffer.""" + csbi = CONSOLE_SCREEN_BUFFER_INFO() + GetConsoleScreenBufferInfo(stdout_handle, byref(csbi)) + return csbi.wAttributes + +def set_text_attr(color): + """Sets the character attributes (colors) of the console screen + buffer. Color is a combination of foreground and background color, + foreground and background intensity.""" + SetConsoleTextAttribute(stdout_handle, color) diff --git a/launcher.bat b/launcher.bat new file mode 100644 index 0000000..a4b9878 --- /dev/null +++ b/launcher.bat @@ -0,0 +1,60 @@ +@Echo Off +:: This first title is used to store the registry setting +:: 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 _Width=122 +Set _BHeight=5000 +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 _yPos=0 +:: Color values are the same as for the Color command +Set _Color=1E +:: Calculate hex values needed in the registry +Set /A _BufferSize=_BHeight*0x10000+_BWidth +Set /A _WindowPos=_yPos*0x10000+_xPos +Set /A _WindowSize=_Height*0x10000+_Width +:: This command will be passed to the Prompt to change the Title and Prompt +:: 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%" +Goto :EOF +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: Subroutines +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:_OpenCP +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 WindowPosition /T REG_DWORD /D %3 /F +Reg Add "HKCU\Console\%~5" /V WindowSize /T REG_DWORD /D %4 /F +Start "%~5" %COMSPEC% /K %6 +:: Only one single command line is needed to receive user input +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%" diff --git a/setup_build.py b/setup_build.py new file mode 100644 index 0000000..0819e74 --- /dev/null +++ b/setup_build.py @@ -0,0 +1,45 @@ +import sys +from cx_Freeze import setup, Executable + +productName = "ImpraStorage" + +# Dependencies are automatically detected, but it might need fine tuning. +build_exe_options = {"packages": ["os","subprocess","importlib","platform"], "excludes": ["tkinter"]} + +# GUI applications require a different base on Windows (the default is for a +# console application). +base = None +#if sys.platform == "win32": +# base = "Win32GUI" + + + + + + +if 'bdist_msi' in sys.argv: + sys.argv += ['--initial-target-dir', 'C:\InstallDir\\' + productName] + sys.argv += ['--install-script', 'install.py'] + + exe = Executable( + script="imprastorage.py", + base=None, + targetName="ImpraStorage.exe" + ) + setup( + name="ImpraStorage.exe", + version="0.5", + author="Me", + description="Copyright 2012", + executables=[exe], + scripts=[ + 'install.py' + ] + ) +else : + + setup( name = "ImpraStorage", + version = "0.5", + description = "ImpraStorage an imap private access storage", + options = {"build_exe": build_exe_options}, + executables = [Executable("imprastorage.py", base=base)])