0

I have accessed to Pepper robot via ssh. My intention is to find the project folder to see where files are created when the robot create a file via

file = open('test.txt', 'w')
file.write('testing how to save project data')
file.close()

the problem is that I don't know where is saved the project, anyone knows in which path is?

Albert Lazaro de Lara
  • 2,540
  • 6
  • 26
  • 41

1 Answers1

1

For a pure .py script, add this to your script and you will find the directory:

import os
strPath = os.path.dirname(__file__)
print strPath

If your project is installed with Choregraphe, the general directory is /var/persistent/home/nao/.local/share/PackageManager/apps So assuming your .py file is located in the root directory of your project, test.txt will be located in /var/persistent/home/nao/.local/share/PackageManager/apps/<project_name>/test.txt

Edit:

For code inside Choregraphe the solution looks differently.

self.behaviorPath = ALFrameManager.getBehaviorPath(self.behaviorId)
self.logger.info(self.behaviorPath)
Anders_K
  • 982
  • 9
  • 28
  • what should **__file__** be? the name of the project? – Albert Lazaro de Lara Aug 24 '17 at 06:45
  • Python has "magic methods". Just leave it as it is. You can google them; __file__, __main__, __version__, __doc__, etc, – Anders_K Aug 24 '17 at 06:58
  • seems that he can't know what *__file__ is* `global name '__file__' is not defined`. Pepper works using Linux, so it should work, and the project is made with *Choregraphe* – Albert Lazaro de Lara Aug 24 '17 at 07:00
  • Seems that Choreographe is saving the file inside a folder named 'data'. So I needed to know where was the project to see where files are created. The project is in `/.local/share/PackageManager/apps/.lastUploadedChoregrapheBehavior/behavior_1`. Thanks for the help – Albert Lazaro de Lara Aug 24 '17 at 07:22