On Fri, Jun 16, 2017, 23:32 Frank Pinto <fapb8...@gmail.com> wrote: > I'm building an app that needs to do the following things: a) checks a > Google Sheet for email and name of a client, b) logs into a dropbox account > and downloads some files (only those files with the name from the google > sheet), c) does some work on the files d) sends the new files to the > clients with the information from the google sheets. It needs to do this > from the first moment it runs till 7:30 PM local time (using a while loop). > > The problem I'm having is that when it starts running, the first iteration > runs fine. When it gets to the second, the google sheets function I created > that accesses the data of the sheets does not work (even though it did the > first time). The console yields the following error: > > "FileNotFoundError: [Errno 2] No such file or directory: 'client_id.json'" >
My best guess is some of your code which you haven't shown us is calling `os.chdir()` and then you're not moving back. When I encounter this problem I usually mitigate it using a context manager something like this: @contextlib.contextmanager def pushd(dir): prev = os.getcwd() os.chdir(dir) yield os.chdir(prev) And then with pushd(dir): Stuff in the dir This is weird, because the json file obviously is not moved in between > runs. Here's an overview of the structure of the code: But it is just a guess, as your intention has been mangled somewhere along the way, and in any case the code seems to be missing parts. -- -- Matt Wheeler http://funkyh.at -- https://mail.python.org/mailman/listinfo/python-list