adding verbosity..

This commit is contained in:
q
2016-10-30 12:33:10 +02:00
parent 2c7b94acce
commit 4219c41ff3
4 changed files with 15 additions and 10 deletions

View File

@@ -1,4 +1,5 @@
#!/usr/bin/python #!/usr/bin/python
# coding=UTF-8
import sys import sys
import os,time,datetime import os,time,datetime
import sqlite3 import sqlite3
@@ -115,7 +116,7 @@ def start_sync(options):
(SRC,TGT)=sync (SRC,TGT)=sync
if not SRC: if not SRC:
return return
print("Starting: #%d %s -> %s"%(i+1,SRC,TGT)) print("Starting: #%d %s ─▶ %s"%(i+1,SRC,TGT))
syncopts=shlex.split(options.options) syncopts=shlex.split(options.options)
command=['rsync'] command=['rsync']
command.extend(syncopts) command.extend(syncopts)
@@ -129,7 +130,7 @@ def start_sync(options):
if '\n' in line: if '\n' in line:
j+=1 j+=1
if j%50==0: if j%50==0:
line=line.replace("\n","\n#%d %s -> %s\n"%(i+1,SRC,TGT),1) line=line.replace("\n","\n#%d/%d %s ─▶ %s\n"%(i+1,len(sync_list),SRC,TGT),1)
j=1 j=1
sys.stdout.write(line) sys.stdout.write(line)
sys.stdout.flush() sys.stdout.flush()
@@ -142,8 +143,8 @@ def start_sync(options):
lines_iterator = iter(popen.stderr.readline, b"") lines_iterator = iter(popen.stderr.readline, b"")
for line in lines_iterator: for line in lines_iterator:
sys.stdout.write(line) sys.stdout.write(line)
print("FAILED: EC: %d, %s -> %s"%(popen.returncode,SRC,TGT)) print("FAILED: EC: %d, %s ─▶ %s"%(popen.returncode,SRC,TGT))
print("Finished: #%d %s -> %s"%(i+1,SRC,TGT)) print("Finished: #%d %s ─▶ %s"%(i+1,SRC,TGT))
def main(): def main():
options=setup_options(); options=setup_options();
@@ -151,7 +152,7 @@ def main():
if not os.path.exists(options.sqlfile): if not os.path.exists(options.sqlfile):
createdb(options.sqlfile); createdb(options.sqlfile);
if options.SRC!='' and options.TGT!='': if options.SRC!='' and options.TGT!='':
print("Adding: %s -> %s"%(options.SRC,options.TGT)) print("Adding: %s ─▶ %s"%(options.SRC,options.TGT))
add(options) add(options)
if options.clear: if options.clear:
print("Clearing database") print("Clearing database")

View File

@@ -98,3 +98,6 @@ class code:
return self.custom_match.sub('\033[\\2',s) return self.custom_match.sub('\033[\\2',s)
def custom_nocolor(self,s): def custom_nocolor(self,s):
return self.custom_match.sub('',s) return self.custom_match.sub('',s)
def get_keys(self):
return self.color_keys

View File

@@ -11,14 +11,15 @@ __version__ = "0.2"
''' Rules modified from mistune project ''' ''' Rules modified from mistune project '''
def setup_options(): def setup_options():
bc=ansi.code()
''' Create command line options ''' ''' Create command line options '''
usage=''' usage='''
Markdown syntax color in ansi codes. Markdown syntax color in ansi codes.
Special syntaxes: Special syntaxes:
* Colors: insert string ${C}, where C is one of KRGBYMCWkrgbymcwSUZ Colors: insert string ${C}, where C is one of %s.
* Any ANSI control code: ${3A}, ${1;34;42m}, etc.. Any ANSI control code: ${3A}, ${1;34;42m}, etc..
''' '''%(" ".join(bc.get_keys()))
parser=ArgumentParser(description=usage, parser=ArgumentParser(description=usage,
epilog=__author__) epilog=__author__)

View File

@@ -32,9 +32,9 @@ def setup_options():
usage=''' usage='''
Color notation renderer in ANSI codes Color notation renderer in ANSI codes
Special syntaxes: Special syntaxes:
* Colors: insert string ${C}, where C is one of KRGBYMCWkrgbymcwSUZ * Colors: insert string ${X}, where X is one of %s.
''' '''%(" ".join(bc.get_keys()))
parser=ArgumentParser(description=usage, parser=ArgumentParser(description=usage,
formatter_class=argparse.RawDescriptionHelpFormatter, formatter_class=argparse.RawDescriptionHelpFormatter,