doe not bring success before write

This commit is contained in:
chrys 2018-06-04 08:38:39 +02:00
parent 4ea9740849
commit cee38f304d
2 changed files with 16 additions and 11 deletions

View File

@ -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.')

View File

@ -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.')