Coloriz in compat mode unix & w32

This commit is contained in:
a-Sansara 2012-09-20 23:55:37 +02:00
parent 370d010b2c
commit 7a838d2317
6 changed files with 349 additions and 133 deletions

View File

@ -34,9 +34,12 @@ import sys, os, platform
import impra.crypt as crypt import impra.crypt as crypt
import impra.util as util import impra.util as util
import impra.core as core import impra.core as core
from impra.util import C from impra.util import Clz
LINE_SEP = C.IBLACK+''*120+C.OFF
LINE_SEP_LEN = 120
LINE_SEP_CHAR = ''
if not Clz.isUnix : LINE_SEP_CHAR = '-'
APP_TITLE = 'ImpraStorage' APP_TITLE = 'ImpraStorage'
APP_VERSION = '0.5' APP_VERSION = '0.5'
APP_AUTHOR = 'a-Sansara' APP_AUTHOR = 'a-Sansara'
@ -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): class _OptionParser(OptionParser):
"""A simplified 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() noData = impst.index.isEmpty()
if uid == None or noData : uid = 'EMPTY' if uid == None or noData : uid = 'EMPTY'
if date == None or noData : date = '' if date == None or noData : date = ''
impst.index.print('\ core.clear()
'+LINE_SEP+'\n\ printLineSep(LINE_SEP_CHAR,LINE_SEP_LEN)
%s -- %s -- %s ' % (C.ON_IBLUE+C.BWHITE , APP_TITLE , C.OFF+C.BYELLOW)+'\ printHeaderTitle(APP_TITLE)
%s[%saccount%s:%s%s%s]%s ' % (C.BIBLACK,C.BYELLOW,C.BIBLACK,C.BBLUE, account , C.BIBLACK, C.BYELLOW)+'\ printHeaderPart('account',account)
%s[%sindex%s:%s%s%s]%s ' % (C.BIBLACK,C.BYELLOW,C.BIBLACK,C.BBLUE, uid , C.BIBLACK, C.BYELLOW)+'\ printHeaderPart('index',uid)
%s[%sbox%s:%s%s%s]%s ' % (C.BIBLACK,C.BYELLOW,C.BIBLACK,C.BBLUE, impst.rootBox , C.BIBLACK, C.BYELLOW)+'\ printHeaderPart('box',impst.rootBox)
%s%s%s ' % (C.BWHITE , date , C.OFF+C.BYELLOW)+'\n'+LINE_SEP) 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') status, resp = impst.ih.srv.search(None, '(SUBJECT "%s")' % '584d15abeb71fbd92fa5861970088b32ebb1d2d6650cec6115a28b64877d70f2')
ids = [m for m in resp[0].split()] ids = [m for m in resp[0].split()]

View File

@ -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 re import split as regsplit, match as regmatch, compile as regcompile, search as regsearch
from time import time from time import time
from impra.imap import ImapHelper, ImapConfig 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 from impra.crypt import Kirmah, ConfigKey, Noiser, Randomiz, hash_sha256, hash_md5_file, BadKeyException
LINE_SEP = C.IBLACK+''*120+C.OFF
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~ class FSplitter ~~ # ~~ class FSplitter ~~
@ -393,43 +392,34 @@ class ImpraIndex:
def print(self,header='', matchIds=None): def print(self,header='', matchIds=None):
"""Print index content as formated bloc""" """Print index content as formated bloc"""
data = self.toString(matchIds).split(self.SEP_ITEM) #clear()
clear() if header is not '':print(header)
print(header) from impra.cli import printLineSep, LINE_SEP_LEN, LINE_SEP_CHAR
print(C.ON_IBLACK+' \ #printLineSep(LINE_SEP_CHAR,LINE_SEP_LEN)
%s%s%s' % (C.BYELLOW,'ID' ,' '*1 )+'\ Clz.print(' ID'+' '*1, Clz.BG4+Clz.fgB7, False, False)
%s%s%s' % (C.BYELLOW,'HASH' ,' '*15)+'\ print('HASH' +' '*15, end='')
%s%s%s' % (C.BYELLOW,'LABEL' ,' '*38)+'\ print('LABEL' +' '*38, end='')
%s%s%s' % (C.BYELLOW,'PART' ,' '*2 )+'\ print('PART' +' '*2 , end='')
%s%s%s' % (C.BYELLOW,'TYPE' ,' '*2 )+'\ print('TYPE' +' '*2 , end='')
%s%s%s' % (C.BYELLOW,'OWNER' ,' '*12)+'\ print('OWNER' +' '*12, end='')
%s%s%s' % (C.BYELLOW,'CATEGORY',' '*17)+C.OFF+'\n'+LINE_SEP) Clz.print('CATEGORY'+' '*17, Clz.BG4+Clz.fgB7)
for row in data: printLineSep(LINE_SEP_CHAR,LINE_SEP_LEN)
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"""
data = '' data = ''
r = [k for i, k in enumerate(self.dic) if not k.startswith(self.SEP_KEY_INTERN)] r = [k for i, k in enumerate(self.dic) if not k.startswith(self.SEP_KEY_INTERN)]
for k in r : for k in r :
v = self.dic.get(k) v = self.dic.get(k)
k = k.lstrip('\n\r') k = k.lstrip('\n\r')
if not k[0]==self.SEP_KEY_INTERN and len(k)>1: if not k[0]==self.SEP_KEY_INTERN and len(k)>1:
if matchIds==None or v[self.UID] in matchIds: 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) Clz.print(str(v[self.UID]).rjust(1+ceil(len(str(v[self.UID]))/10),' ') +' '*2, Clz.fgB1, False)
data += '%s%s%s' % (C.IGREEN , str(k)[0:12]+'... ' , ' '*2) Clz.print(str(k)[0:12]+'... ' +' '*2, Clz.fgn2, False)
data += '%s%s%s' % (C.BWHITE , str(v[self.LABEL]).ljust(42,' ') , ' '*2) Clz.print(str(v[self.LABEL]).ljust(42,' ') +' '*2, Clz.fgB7, False)
data += '%s%s%s' % (C.BPURPLE , str(v[self.PARTS]).rjust(2 ,'0') , ' '*2) Clz.print(str(v[self.PARTS]).rjust(2 ,'0') +' '*2, Clz.fgB5, False)
data += '%s%s%s' % (C.BIGREEN , str(v[self.EXT]).ljust(5,' ') , ' '*2) Clz.print(str(v[self.EXT]).ljust(5,' ') +' '*2, Clz.fgB4, False)
data += '%s%s%s' % (C.BWHITE , self.getUser(str(v[self.OWNER])).ljust(15,' ') , ' '*2) Clz.print(self.getUser(str(v[self.OWNER])).ljust(15,' ') +' '*2, Clz.fgB7, False)
data += '%s%s%s' % (C.BBLUE , str(v[self.CATG]) , ' '*2) Clz.print(str(v[self.CATG]) +' '*2, Clz.fgB4)
#~ elif len(k)>1: printLineSep(LINE_SEP_CHAR,LINE_SEP_LEN)
#~ print(k,'=',v)
data = data+self.SEP_ITEM
return data;
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -37,9 +37,9 @@ from math import log, floor, ceil
from os import urandom, popen, sep, makedirs, system from os import urandom, popen, sep, makedirs, system
from os.path import dirname, realpath, abspath, join from os.path import dirname, realpath, abspath, join
from random import choice 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 subprocess import PIPE, Popen
from sys import stderr, executable as pyexec from sys import stderr, executable as pyexec, stdout
import platform import platform
#~ from sys.stdout import isatty #~ from sys.stdout import isatty
from time import time from time import time
@ -213,8 +213,11 @@ class RuTime:
def _start(self): def _start(self):
global C global Clz
if self.debug :print(C.BRED+' ==> '+C.BYELLOW+self._paramize(self.label)+C.OFF) if self.debug :
Clz.print(' ==> ', Clz.fgb1, False)
self._paramize(self.label)
Clz.print('', Clz.OFF)
self.sc = time() self.sc = time()
def stop(self): def stop(self):
@ -223,14 +226,21 @@ class RuTime:
if self.debug: self._stats() if self.debug: self._stats()
def _paramize(self,data): def _paramize(self,data):
global C global Clz
s = data.replace('(','('+C.GREEN) sp = [m.start() for m in regfinditer('\(', data)]
s = s.replace(')',C.BYELLOW+')'+C.OFF) ep = [m.start() for m in regfinditer('\)', data)]
return s 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): def _stats(self):
global C global Clz
print(C.BRED+' <== '+C.BYELLOW+self._paramize(self.label)+(' %s%.5f s%s' % (C.WHITE,self.ec-self.sc,C.OFF))) 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: class Coloriz:
# Reset _MARKER = ''
OFF ='\033[1;m' """"""
_SEP = ';'
# Regular Colors """"""
BLACK ='\033[0;30m' _PATTERN_COLOR = '^'+_MARKER[0]+'[nfNFbB][0-7]'+_SEP+'$'
RED ='\033[0;31m' """"""
GREEN ='\033[0;32m' _wFH = 0x0008
YELLOW ='\033[0;33m' """"""
BLUE ='\033[0;34m' _wBH = 0x0080
PURPLE ='\033[0;35m' """"""
CYAN ='\033[0;36m' _uOFF = '\033[1;m'
WHITE ='\033[0;37m' """"""
_wOFF = None
# Bold """"""
BBLACK ='\033[1;30m' _LF = '\n'
BRED ='\033[1;31m' """"""
BGREEN ='\033[1;32m' OFF = _MARKER+_MARKER[0]+'OFF'+_SEP+_MARKER
BYELLOW ='\033[1;33m' """"""
BBLUE ='\033[1;34m' isUnix = platform.system() != 'Windows'
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'
def __init__(self): def __init__(self):
"""""" """Colors for both plateform are : 0: black - 1: red - 2:green - 3: yellow - 4: blue - 5: purple - 6: cyan - 7: white
global COLOR_MODE available class members :
if not COLOR_MODE : foreground normal (same as bold for w32):
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 = '' 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
C = Coloriz() 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
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()

75
impra/w32color.py Normal file
View File

@ -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)

60
launcher.bat Normal file
View File

@ -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%"

45
setup_build.py Normal file
View File

@ -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)])