fix ponysay-tool installation

Signed-off-by: Mattias Andrée <maandree@operamail.com>
This commit is contained in:
Mattias Andrée 2013-04-04 14:14:09 +02:00
parent 7bbc0a0266
commit 298679fecf
3 changed files with 65 additions and 74 deletions

View file

@ -558,17 +558,17 @@ class Setup():
if hasponies and os.path.isdir(sharedir):
for toolcommand in ('--dimensions', '--metadata'):
if not self.free:
print('%s, %s, %s' % ('./src/ponysay-tool.py', toolcommand, sharedir))
Popen(['./src/ponysay-tool.py', toolcommand, sharedir], stdin=PIPE, stdout=PIPE, stderr=PIPE).communicate()
print('%s, %s, %s' % ('./src/ponysaytool.py', toolcommand, sharedir))
Popen(['./src/ponysaytool.py', toolcommand, sharedir], stdin=PIPE, stdout=PIPE, stderr=PIPE).communicate()
else:
params = ['./src/ponysay-tool.py', toolcommand, sharedir, '--']
params = ['./src/ponysaytool.py', toolcommand, sharedir, '--']
for sharefile in os.listdir(sharedir):
if sharefile.endswith('.pony') and (sharefile != '.pony'):
if not Setup.validateFreedom(sharedir + '/' + sharefile):
print('Skipping metadata correction for %s/%s, did not pass validation process made by setup settings' % (sharedir, sharefile))
else:
params.append(sharefile)
print('%s, %s, %s (with files)' % ('./src/ponysay-tool.py', toolcommand, sharedir))
print('%s, %s, %s (with files)' % ('./src/ponysaytool.py', toolcommand, sharedir))
Popen(params, stdin=PIPE, stdout=PIPE, stderr=PIPE).communicate()
print()

View file

@ -56,8 +56,7 @@ if __name__ == '__main__':
istool = istool[:istool.find(os.extsep)]
istool = istool.endswith('-tool')
if istool:
from ponysaytool import *
startponysaytool()
from ponysaytool import * ## will start ponysay-tool
exit(0)
isthink = sys.argv[0]

View file

@ -1184,33 +1184,29 @@ class TextArea(): # TODO support small screens
'''
Start the program
The user's home directory
'''
def startponysaytool():
'''
The user's home directory
'''
HOME = os.environ['HOME'] if 'HOME' in os.environ else os.path.expanduser('~')
HOME = os.environ['HOME'] if 'HOME' in os.environ else os.path.expanduser('~')
'''
Whether stdin is piped
'''
pipelinein = not sys.stdin.isatty()
'''
Whether stdin is piped
'''
pipelinein = not sys.stdin.isatty()
'''
Whether stdout is piped
'''
pipelineout = not sys.stdout.isatty()
'''
Whether stdout is piped
'''
pipelineout = not sys.stdout.isatty()
'''
Whether stderr is piped
'''
pipelineerr = not sys.stderr.isatty()
'''
Whether stderr is piped
'''
pipelineerr = not sys.stderr.isatty()
usage_program = '\033[34;1mponysay-tool\033[21;39m'
usage_program = '\033[34;1mponysay-tool\033[21;39m'
usage = '\n'.join(['%s %s' % (usage_program, '(--help | --version | --kms)'),
usage = '\n'.join(['%s %s' % (usage_program, '(--help | --version | --kms)'),
'%s %s' % (usage_program, '(--edit | --edit-rm) \033[33mPONY-FILE\033[39m'),
'%s %s' % (usage_program, '--edit-stash \033[33mPONY-FILE\033[39m > \033[33mSTASH-FILE\033[39m'),
'%s %s' % (usage_program, '--edit-apply \033[33mPONY-FILE\033[39m < \033[33mSTASH-FILE\033[39m'),
@ -1218,41 +1214,37 @@ def startponysaytool():
'%s %s' % (usage_program, '--browse \033[33mPONY-DIR\033[39m [-r \033[33mRESTRICTION\033[39m]*'),
])
usage = usage.replace('\033[', '\0')
for sym in ('[', ']', '(', ')', '|', '...', '*'):
usage = usage.replace('\033[', '\0')
for sym in ('[', ']', '(', ')', '|', '...', '*'):
usage = usage.replace(sym, '\033[2m' + sym + '\033[22m')
usage = usage.replace('\0', '\033[')
usage = usage.replace('\0', '\033[')
'''
Argument parsing
'''
opts = ArgParser(program = 'ponysay-tool',
'''
Argument parsing
'''
opts = ArgParser(program = 'ponysay-tool',
description = 'Tool chest for ponysay',
usage = usage,
longdescription = None)
opts.add_argumentless(['--no-term-init']) # for debugging
opts.add_argumentless(['--no-term-init']) # for debugging
opts.add_argumentless(['-h', '--help'], help = 'Print this help message.')
opts.add_argumentless(['-v', '--version'], help = 'Print the version of the program.')
opts.add_argumentless(['--kms'], help = 'Generate all kmsponies for the current TTY palette')
opts.add_argumented( ['--dimensions'], arg = 'PONY-DIR', help = 'Generate pony dimension file for a directory')
opts.add_argumented( ['--metadata'], arg = 'PONY-DIR', help = 'Generate pony metadata collection file for a directory')
opts.add_argumented( ['-b', '--browse'], arg = 'PONY-DIR', help = 'Browse ponies in a directory')
opts.add_argumented( ['-r', '--restrict'], arg = 'RESTRICTION', help = 'Metadata based restriction for --browse')
opts.add_argumented( ['--edit'], arg = 'PONY-FILE', help = 'Edit a pony file\'s metadata')
opts.add_argumented( ['--edit-rm'], arg = 'PONY-FILE', help = 'Remove metadata from a pony file')
opts.add_argumented( ['--edit-apply'], arg = 'PONY-FILE', help = 'Apply metadata from stdin to a pony file')
opts.add_argumented( ['--edit-stash'], arg = 'PONY-FILE', help = 'Print applyable metadata from a pony file')
opts.add_argumentless(['-h', '--help'], help = 'Print this help message.')
opts.add_argumentless(['-v', '--version'], help = 'Print the version of the program.')
opts.add_argumentless(['--kms'], help = 'Generate all kmsponies for the current TTY palette')
opts.add_argumented( ['--dimensions'], arg = 'PONY-DIR', help = 'Generate pony dimension file for a directory')
opts.add_argumented( ['--metadata'], arg = 'PONY-DIR', help = 'Generate pony metadata collection file for a directory')
opts.add_argumented( ['-b', '--browse'], arg = 'PONY-DIR', help = 'Browse ponies in a directory')
opts.add_argumented( ['-r', '--restrict'], arg = 'RESTRICTION', help = 'Metadata based restriction for --browse')
opts.add_argumented( ['--edit'], arg = 'PONY-FILE', help = 'Edit a pony file\'s metadata')
opts.add_argumented( ['--edit-rm'], arg = 'PONY-FILE', help = 'Remove metadata from a pony file')
opts.add_argumented( ['--edit-apply'], arg = 'PONY-FILE', help = 'Apply metadata from stdin to a pony file')
opts.add_argumented( ['--edit-stash'], arg = 'PONY-FILE', help = 'Print applyable metadata from a pony file')
'''
Whether at least one unrecognised option was used
'''
unrecognised = not opts.parse()
'''
Whether at least one unrecognised option was used
'''
unrecognised = not opts.parse()
PonysayTool(args = opts)
if __name__ == '__main__':
startponysaytool()
PonysayTool(args = opts)