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,16 +16,18 @@ def addScreenToIgnoreList(ignoreFileName = '/tmp/fenrirSuspend', screen = '1', u
ignoreScreens = fp.read().split(',')#.replace('\n','').split(',') ignoreScreens = fp.read().split(',')#.replace('\n','').split(',')
except Exception as e: except Exception as e:
print(e) print(e)
added = False
if not screen in ignoreScreens: if not screen in ignoreScreens:
ignoreScreens.extend(screen) ignoreScreens.extend(screen)
print('Add screen {0} to ignore file:{1}'.format(screen, ignoreFileName)) added = True
else:
print('Screen {0} already exists in ignore file:{1}'.format(screen, ignoreFileName))
ignoreScreensStr = ','.join(ignoreScreens) ignoreScreensStr = ','.join(ignoreScreens)
with open(ignoreFileName, 'w') as fp: 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__": if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Ignore screens in fenrir. If no screen is given use current screen.') parser = argparse.ArgumentParser(description='Ignore screens in fenrir. If no screen is given use current screen.')

View File

@ -16,16 +16,19 @@ def removeScreenFromIgnoreList(ignoreFileName = '/tmp/fenrirSuspend', screen = '
ignoreScreens = fp.read().split(',')#.replace('\n','').split(',') ignoreScreens = fp.read().split(',')#.replace('\n','').split(',')
except Exception as e: except Exception as e:
print(e) print(e)
removed = False
if screen in ignoreScreens: if screen in ignoreScreens:
ignoreScreens.remove(screen) ignoreScreens.remove(screen)
print('Remove screen {0} to ignore file:{1}'.format(screen, ignoreFileName)) removed = True
else:
print('Screen {0} does not exists in ignore file:{1}'.format(screen, ignoreFileName))
ignoreScreensStr = ','.join(ignoreScreens) ignoreScreensStr = ','.join(ignoreScreens)
with open(ignoreFileName, 'w') as fp: with open(ignoreFileName, 'w') as fp:
fp.write(ignoreScreensStr) 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__": 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 = argparse.ArgumentParser(description='Unignore screens in fenrir to make it active again. If no screen is given use current screen.')