jayvdb created this task.
jayvdb added subscribers: jayvdb, XZise.
jayvdb added a project: pywikibot-core.
Restricted Application added subscribers: Aklapper, pywikibot-bugs.

TASK DESCRIPTION
  We need a bit of a plan for how pywikibot should report the version on the 
console.
  
  Most cmdline tools have a --version , which in pwb land would be -version, 
however that doesnt work as it is a global argument
  
  ```
  $ python pwb.py --version
  Traceback (most recent call last):
    File "pwb.py", line 219, in <module>
      if not main():
    File "pwb.py", line 186, in main
      raise OSError("%s not found!" % filename)
  OSError: --version.py not found!
  <type 'exceptions.OSError'>
  CRITICAL: Closing network session.
  
  $ python pwb.py -version
  Traceback (most recent call last):
    File "pwb.py", line 219, in <module>
      if not main():
    File "pwb.py", line 186, in main
      raise OSError("%s not found!" % filename)
  OSError: -version.py not found!
  <type 'exceptions.OSError'>
  CRITICAL: Closing network session.
  
  $ python pwb.py replace --version
  ERROR: Incomplete command line pattern replacement pair.
  
  $ python pwb.py replace -version
  ERROR: Incomplete command line pattern replacement pair.
  
  ```
  
  Pywikibot provides this information via a script
  
  ```
  $ python pwb.py version
  Pywikibot: [ssh] pywikibot-core.git (1bba780, g5711, 2015/06/09, 19:51:38, 
OUTDATED)
  Release version: 2.0b3
  requests version: 2.2.1
    cacerts: /usr/lib/python2.7/site-packages/requests/cacert.pem
      certificate test: ok
  Python: 2.7.5 (default, Apr 10 2015, 08:09:05) 
  [GCC 4.8.3 20140911 (Red Hat 4.8.3-7)]
    unicode test: ok
  PYWIKIBOT2_DIR: Not set
  PYWIKIBOT2_DIR_PWB: 
  PYWIKIBOT2_NO_USER_CONFIG: Not set
  Config base dir: /home/jayvdb/.pywikibot
  Usernames for family "wikipedia":
        test: JVbot-test (John Vandenberg)
        en: JVbot-test (no sysop configured)
  ```
  
  Due to the fact we support nightlies, svn, git, and now a package, and 
provide support to shared environments like the labs, it is important to have a 
script which can be run even when the 'pywikibot' package cant be found, and 
when other dependencies cant be found.  Enter a patch that does this: 
https://gerrit.wikimedia.org/r/#/c/216876/
  
  However 'scripts/version.py' is not packaged as part of the official package.
  
  If we are going to have some of this information available via a --version 
global command line argument, where does it go, and how is it displayed when 
the pywikibot package cant be loaded.
  
  Some initial thoughts:
  - the usernames listings are a prettier edition of the output of 'python 
pwb.py pywikibot/config2.py modified' - however running that command is not 
documented anywhere as far as I know, and it is a bit odd.
  - pwb.py is where we typically place startup debugging information, such as 
failed dependencies.  however it exit's on the first error, and we need a 
command which lists all of the information so it is easier to understand the 
clients environment remotely.
  - the unicode test doesnt need to be included ; we know which versions are 
broken, so we can and I believe should warn (every startup) when those versions 
are used, or when the relevant features are accessed.
  
  So, a rough plan is
  - move the config usernames code into config2.py, into a new function , using 
'print' rather than pywikibot.output as config2.py 's __main__ already does
  - move the unicode test into tests/ and replace it with version detection and 
warn( ) / error messages
  - add -debug and -version support to pwb.py and bot.py , so that they output 
the same thing roughly , with pwb.py not exiting on the first error.

TASK DETAIL
  https://phabricator.wikimedia.org/T101828

EMAIL PREFERENCES
  https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: jayvdb
Cc: XZise, jayvdb, Aklapper, pywikibot-bugs



_______________________________________________
pywikibot-bugs mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-bugs

Reply via email to