From 34d0b21b12f3e0c40fcd4756024d065c9613a7e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Andr=C3=A9e?= Date: Thu, 4 Apr 2013 03:23:26 +0200 Subject: [PATCH] fix ponysay-tool --kms MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- setup.py | 4 ++-- src/kms.py | 12 +++++++++--- src/ponysay-tool.py | 7 ++++++- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index 12b51e7b..642e0a63 100755 --- a/setup.py +++ b/setup.py @@ -601,8 +601,8 @@ class Setup(): os.makedirs(pdir) print('Creating directory ' + dir) os.mkdir(dir) - print('Setting permission mode mask for ' + dir + ' to 6777') - Popen('chmod -R 6777 -- \'' + dir.replace('\'', '\'\\\'\'') + '\'', shell=True).wait() + print('Setting permission mode mask for ' + dir + ' to 7777') + Popen('chmod -R 7777 -- \'' + dir.replace('\'', '\'\\\'\'') + '\'', shell=True).wait() print('Setting group for ' + dir + ' users') Popen('chown -R :users -- \'' + dir.replace('\'', '\'\\\'\'') + '\'', shell=True).wait() for shell in [item[0] for item in shells]: diff --git a/src/kms.py b/src/kms.py index bf0d70b0..43b95806 100755 --- a/src/kms.py +++ b/src/kms.py @@ -128,7 +128,10 @@ class KMS(): with open(cachedir + '/.version', 'w+') as cachev: cachev.write(KMS_VERSION) if shared: - os.chmod(_cachedir + '/.version', 0o666) + try: + os.chmod(cachedir + '/.version', 0o666) + except: + pass ## Get kmspony directory and kmspony file kmsponies = cachedir + '/kmsponies/' + palettefile @@ -147,14 +150,17 @@ class KMS(): if not os.path.isdir(kmsponydir): os.makedirs(kmsponydir) if shared: - Popen('chmod -R 6777 -- ' + _cachedir, shell=True).wait() + Popen('chmod -R 7777 -- ' + _cachedir, shell=True).wait() ponytoolcmd = 'ponytool --import ponysay --file %s --export ponysay --file %s --platform linux ' ponytoolcmd += '--balloon n --colourful y --fullcolour y --left - --right - --top - --bottom - --palette %s' if not os.system(ponytoolcmd % (_pony, _kmspony, palette)) == 0: printerr('Unable to run ponytool successfully, you need util-say>=3 for KMS support') exit(1) if shared: - os.chmod(_kmspony, 0o666) + try: + os.chmod(kmspony, 0o666) + except: + pass return kmspony diff --git a/src/ponysay-tool.py b/src/ponysay-tool.py index 02a2f001..f0465f4e 100755 --- a/src/ponysay-tool.py +++ b/src/ponysay-tool.py @@ -438,7 +438,7 @@ class PonysayTool(): class PhonyArgParser(): def __init__(self, key, value): self.argcount = 3 - self.message = ponyfile + self.message = '' self.opts = self self.key = key self.value = value @@ -464,6 +464,8 @@ class PonysayTool(): return True stdout = sys.stdout + term = os.environ['TERM'] + os.environ['TERM'] = 'linux' sys.stdout = StringInputStream() ponysay = Ponysay() @@ -477,16 +479,19 @@ class PonysayTool(): for pony in stdponies: printerr('Genering standard kmspony: %s' % pony) + sys.stderr.buffer.flush(); sys.stdout = StringInputStream() ponysay = Ponysay() ponysay.run(PhonyArgParser('--pony', pony)) for pony in extraponies: printerr('Genering extra kmspony: %s' % pony) + sys.stderr.buffer.flush(); sys.stdout = StringInputStream() ponysay = Ponysay() ponysay.run(PhonyArgParser('++pony', pony)) + os.environ['TERM'] = term sys.stdout = stdout