From cee38f304dbc91e1c6d88f352c6f5591a74d6caf Mon Sep 17 00:00:00 2001 From: chrys Date: Mon, 4 Jun 2018 08:38:39 +0200 Subject: [PATCH] doe not bring success before write --- tools/fenrir-ignore-screen | 14 ++++++++------ tools/fenrir-unignore-screen | 13 ++++++++----- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/tools/fenrir-ignore-screen b/tools/fenrir-ignore-screen index 6a88c1cd..f19735e5 100755 --- a/tools/fenrir-ignore-screen +++ b/tools/fenrir-ignore-screen @@ -16,17 +16,19 @@ def addScreenToIgnoreList(ignoreFileName = '/tmp/fenrirSuspend', screen = '1', u ignoreScreens = fp.read().split(',')#.replace('\n','').split(',') except Exception as e: print(e) - + added = False if not screen in ignoreScreens: ignoreScreens.extend(screen) - print('Add screen {0} to ignore file:{1}'.format(screen, ignoreFileName)) - else: - print('Screen {0} already exists in ignore file:{1}'.format(screen, ignoreFileName)) + added = True ignoreScreensStr = ','.join(ignoreScreens) with open(ignoreFileName, 'w') as fp: - fp.write(ignoreScreensStr) - + fp.write(ignoreScreensStr) + if added: + print('Add screen {0} to ignore file:{1}'.format(screen, ignoreFileName)) + else: + print('Screen {0} already exists in ignore file:{1}'.format(screen, ignoreFileName)) + if __name__ == "__main__": parser = argparse.ArgumentParser(description='Ignore screens in fenrir. If no screen is given use current screen.') parser.add_argument('-s', '--screen', metavar='SCREEN', default=None, help='Ignore a given screen. Use current screen as default.') diff --git a/tools/fenrir-unignore-screen b/tools/fenrir-unignore-screen index b62619b6..c69b47f9 100755 --- a/tools/fenrir-unignore-screen +++ b/tools/fenrir-unignore-screen @@ -16,17 +16,20 @@ def removeScreenFromIgnoreList(ignoreFileName = '/tmp/fenrirSuspend', screen = ' ignoreScreens = fp.read().split(',')#.replace('\n','').split(',') except Exception as e: print(e) - + removed = False if screen in ignoreScreens: ignoreScreens.remove(screen) - print('Remove screen {0} to ignore file:{1}'.format(screen, ignoreFileName)) - else: - print('Screen {0} does not exists in ignore file:{1}'.format(screen, ignoreFileName)) + removed = True + ignoreScreensStr = ','.join(ignoreScreens) with open(ignoreFileName, 'w') as fp: fp.write(ignoreScreensStr) - + if removed: + print('Remove screen {0} to ignore file:{1}'.format(screen, ignoreFileName)) + else: + print('Screen {0} does not exists in ignore file:{1}'.format(screen, ignoreFileName)) + if __name__ == "__main__": parser = argparse.ArgumentParser(description='Unignore screens in fenrir to make it active again. If no screen is given use current screen.') parser.add_argument('-s', '--screen', metavar='SCREEN', default=None, help='Ignore a given screen. Use current screen as default.')