Guest User

Untitled

a guest
Jul 16th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. import logging
  2. filepath = os.path.join(os.path.dirname(ALFrameManager.getBehaviorPath(self.behaviorId)), "fileName.txt")
  3. maybeContains = None
  4. try:
  5. with open(filepath, "r") as textfile:
  6. maybeContains = textfile.readlines()
  7. except:
  8. pass
  9. with open(filepath, "a") as textfile:
  10. if maybeContains == "":
  11. agenda = "type1;type2;n"
  12. textfile.write(agenda)
  13. textfile.write(storedData)
  14. else:
  15. textfile.write(storedData)
  16. self.onStopped()
  17.  
  18. def onLoad(self):
  19. self.logging.basicConfig(filename="20180712.log", format='%(asctime)s %(levelname)s-8s [%(filename)s:%(lineno)d]%(message)s', level=logging.DEBUG)
  20. self.logger = self.logging.getLogger("Behavior - Box") `
  21.  
  22. Before a command, which should be logged I call
  23. ` self.logger("what happened here")
  24.  
  25. filepath = "/home/nao/myfile.txt"
Add Comment
Please, Sign In to add comment