Search code examples
pythoniopicklecanonical-quickly

Quickly runtime and .p files


I am trying to build a application in python using quickly mostly everything is working however when i try to run a function that reads a .p (pickle) file i am getting a I/O error. The strange thing is when i run the same python program in the shell it works fine.

 adam@adam-System-Product-Name:~/reskin/reskin$ quickly run    
      2, No such file or directory,  newSnapShots.p 
    Traceback (most recent call last):
      File "bin/reskin", line 36, in <module> 
        reskin.main()
      File "/home/adam/reskin/reskin/__init__.py", line 31, in main
        window = ReskinWindow.ReskinWindow()
      File "/home/adam/reskin/reskin_lib/Window.py", line 37, in __new__
        new_object.finish_initializing(builder)
      File "/home/adam/reskin/reskin/ReskinWindow.py", line 36, in finish_initializing
        self.set_app_data(builder) 
      File "/home/adam/reskin/reskin/ReskinWindow.py", line 43, in set_app_data
        viewControler.app_by_name("firstVar")
      File "/home/adam/reskin/reskin/back/viewControler.py", line 29, in app_by_name
        app = applicationGetter.get_app_by_name(name)
      File "/home/adam/reskin/reskin/back/applicationGetter.py", line 8, in get_app_by_name
        for snap in savedSnaps:
    TypeError: 'bool' object is not iterable

Function that prints error:

def get_saved_snaps():
try:
    with open('data/newSnapShots.p','rb') as snapFile:
        savedSnaps = pickle.load(snapFile)

except IOError as e:
    print "{0}, {1},  newSnapShots.p ".format(e.errno, e.strerror)
    return False

return savedSnaps

tree of files and .p location

.
├── applicationGetter.py
├── applicationGetter.pyc
├── data
│   └── newSnapShots.p    < file here
├── firstTimeSnapList.py
├── __init__.py
├── __init__.pyc
├── prosessCheckerv3.py
├── prosessScript.sh
├── viewControler.py
└── viewControler.pyc

Is there some issue using Cpickle with quickly should i be using something else instead ? Thank you in advance.


Solution

  • After a little researching it turns out that the dynamic or relative file paths have trouble being executed while quickly is also being executed. So by switching

      def get_saved_snaps():
    try:
        with open('data/newSnapShots.p','rb') as snapFile:
    

    for

    def get_saved_snaps():
    try:
        with open('/absolute_path/quickly_project/data/newSnapShots.p','rb') as snapFile:
    

    The issue was resolved. I don’t know why relative paths behave this way.