fix ponysay-tool --kms

Signed-off-by: Mattias Andrée <maandree@operamail.com>
This commit is contained in:
Mattias Andrée 2013-04-04 03:23:26 +02:00
parent e9c4b63ac7
commit 34d0b21b12
3 changed files with 17 additions and 6 deletions

View file

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

View file

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

View file

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