Last modified: 2014-11-09 20:39:05 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T74503, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 72503 - does not run scripts if does not exist does not run scripts if does not exist
Status: NEW
Product: Pywikibot
Classification: Unclassified
General (Other open bugs)
All All
: Normal normal
: ---
Assigned To: Pywikipedia bugs
Depends on:
Blocks: pwb20
  Show dependency treegraph
Reported: 2014-10-24 23:18 UTC by Betacommand
Modified: 2014-11-09 20:39 UTC (History)
3 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Description Betacommand 2014-10-24 23:18:41 UTC
if is invoked via the framework doesnt generate a family file
Comment 1 John Mark Vandenberg 2014-10-25 16:31:50 UTC
$ python
Usage: <url> <short name>
Example: https://www.mywiki.bogus/wiki/Main_Page mywiki
This will create the file families/
Please insert URL to wiki:
Please insert a short name (eg: freeciv): reuters
Generating family file from
*** WARNING: Api does not seem to be enabled on

api url:
MediaWiki version: 1.11.1

Determining other languages...
Loading wikis... 
  * en... in cache
Writing pywikibot/families/ 
$ cat pywikibot/families/
# -*- coding: utf-8 -*-
This family file was auto-generated by $Id: 78e663f86b4d504a28387ecbf0c2e0e8e549cf4e $
Configuration parameters:
  url =
  name = reuters

Please do not commit this to the Git repository!

from pywikibot import family

class Family(family.Family):
    def __init__(self):
        family.Family.__init__(self) = 'reuters'
        self.langs = {
            'en': '',

    def scriptpath(self, code):
        return {
            'en': '',

    def version(self, code):
        return {
            'en': u'1.11.1',

Please add more detailed steps to reproduce
Comment 2 Betacommand 2014-10-25 18:38:18 UTC
C:\rewrite> mysit
NOTE: '' was not found!
Please follow the prompts to create it:
No found in directory 'C:\rewrite'.

WARNING: Skipping loading of
WARNING: Running on Windows and transliteration_target is not set.
Please see
WARNING: family and mylang are not set.
Defaulting to family='test' and mylang='test'.

Your default user directory is "C:\rewrite"
WARNING: is deprecated, use input_choice instead.
How to proceed? ([K]eep, [c]hange) k
WARNING: is deprecated, use input_choice instead.
Do you want to copy user files from an existing Pywikibot installation? ([y]es,
[n]o) n
WARNING: is deprecated, use input_choice instead.
Create file? Required for running bots. ([y]es, [N]o) n already exists in the directory
Comment 3 Merlijn van Deen (test) 2014-10-25 19:13:24 UTC
Ah, so rather the issue is generate_family_file is not run when no exists. What happens is the following:

- sees no user-config and thus invokes
- you don't want to create a user-config file yet, because you need the to-be-created family for that

The simplest way to fix this is to add a special case for in, as it really *is* a special case. Allowing other scripts to continue would mean using test:test as site, for instance. Essentially it's our config singleton biting us again...
Comment 4 Fabian 2014-10-26 15:18:57 UTC
(In reply to Merlijn van Deen from comment #3)
> Essentially it's our config singleton biting us again...

The current version of 'generate_family_file' could be run without a user config (like generate_user_files). The problem is just that doesn't know that. Although the question is how can we let it know? We could have just a list of files which don't require a user config, but then we need to make sure it's kept in sync with the file name(s).

Or only load the (user) config as soon as the script requires it which would be the default. So in generate_family_file it's setting a environment variable to say "user config is optional" and only then it queries the code to load the config. The problem here is when a file doesn't need it but depends on a file which does. If the default (when nothing is done about it) is to require the user config (so we only need to change generate_family_file) and a file does request that it doesn't need a user config it sets that variable. Later it depends then on something which does require the user config but doesn't set the variable because by default it doesn't need to.

Both scenarios sound like I'm overthinking it so maybe someone has a better and easier idea.

But thinking about it, it'd be nice if generate_family_file knows which family file directories are configured to give the user the configured directories to choose from. But that would require an “load if possible but ignore otherwise” option.
Comment 5 John Mark Vandenberg 2014-11-09 20:36:48 UTC
Or generate_user_files could ask the user if they want to add a family , and invoke generate_family_file

Note You need to log in before you can comment on or make changes to this bug.