Page MenuHomePhabricator

'user-config.py' not found if runs with cron
Closed, ResolvedPublic

Description

After Ic8ac542919e18ad16458d21e0f9713ade899b964 if I try to run a script via command line (foreground), it's executed correctly.
Eg: python pwb.py <script_name>
But when I schedule the same script via cron, it terminates with this error:

NOTE: 'user-config.py' was not found! Please follow the prompts to create it: Traceback (most recent call last): File "/data/project/betabot/core/pwb.py", line 162, in <module> []) File "/data/project/betabot/core/pwb.py", line 74, in run_python_file source = open(filename).read() IOError: [Errno 2] No such file or directory: 'generate_user_files.py'

This is my version:
Pywikibot: [https] r-pywikibot-core.git (178e01a, g4377, 2014/10/26, 22:42:22, OUTDATED)
Release version: 2.0b2
httplib2 version: 0.9

certificate test: ok

Python: 2.7.3 (default, Feb 27 2014, 19:58:35)
[GCC 4.6.3]

unicode test: ok

Please, ask me if you need more information.


Version: core-(2.0)
Severity: major
See Also:
https://bugzilla.wikimedia.org/show_bug.cgi?id=72918

Details

Reference
bz72680

Event Timeline

bzimport raised the priority of this task from to High.Nov 22 2014, 3:44 AM
bzimport set Reference to bz72680.
bzimport added a subscriber: Unknown Object (????).
Beta16 created this task.Oct 29 2014, 3:58 PM

Is your user-config.py in /data/project/betabot/core/ or in ~/.pywikibot ?

XZise added a comment.Oct 29 2014, 4:16 PM

And do you use PYWIKIBOT2_DIR to define the directory. I'm not so knowledgable with cron, but it might not have PYWIKIBOT2_DIR set.

(In reply to John Mark Vandenberg from comment #1)

Is your user-config.py in /data/project/betabot/core/ or in ~/.pywikibot ?

My user-config.py file is in /data/project/betabot/core/

(In reply to Fabian from comment #2)

And do you use PYWIKIBOT2_DIR to define the directory. I'm not so
knowledgable with cron, but it might not have PYWIKIBOT2_DIR set.

I don't use environment variable PYWIKIBOT2_DIR

XZise added a comment.Oct 29 2014, 7:34 PM

Okay this sounds like cron is not in the directory when it is executing pwb.py and it chooses the directory depending on where your console is at the moment.

I'm not sure if that is going to be fixed or how.

This is reported to be a regression. Need to confirm that, and if so, fix it.

  • Bug 72918 has been marked as a duplicate of this bug. ***

gerritadmin wrote:

Change 172096 had a related patch set uploaded by Mpaa:
Bug 72680 - 'user-config.py' not found if runs with cron

https://gerrit.wikimedia.org/r/172096

It breaks all bots with the newest version on toolslabs

gerritadmin wrote:

Change 172096 merged by jenkins-bot:
Bug 72680 - 'user-config.py' not found if runs with cron

https://gerrit.wikimedia.org/r/172096

As a workaround, chdir to the pwb.py path before running, or
explicitly define the user-config path with -dir:/path/where/pwb.py/is
(or check out an older revision).

As far as I can see, the merged patch fixes this. The behaviour /is/ slightly different from before (the current working dir gets prevalence over the pwb.py directory) but this is by design.

Fae added a subscriber: Fae.Aug 30 2016, 10:46 AM