CommandLine

From BITPlan mediawiki-japi Wiki
Revision as of 18:19, 27 March 2020 by Wf (talk | contribs) (→‎Example)
Jump to navigation Jump to search

https://github.com/WolfgangFahl/Mediawiki-Japi/issues/49 has (finally) introduced command line support. The CommandLine has two modes:

  1. Transfer mode
  2. Credential mode

Transfer mode

The main purpose of transfer mode is to push pages from one wiki to another including all files on the page.

Example

 
./run -s wikipedia_org_test -t wikipedia_org_test2 -p PictureTestPage 
Mar 16, 2020 10:29:22 AM com.bitplan.mediawiki.japi.SSLWiki login
INFORMATION: https://test2.wikipedia.org/w/api.php?:Success
File:Mona Lisa one two one two this is just a test.jpg
https://upload.wikimedia.org/wikipedia/test/8/81/Mona_Lisa_one_two_one_two_this_is_just_a_test.jpg
Mar 16, 2020 10:29:29 AM com.bitplan.mediawiki.japi.MediaWikiApiImpl handleError
SCHWERWIEGEND: error code=fileexists-shared-forbidden info:'A file with this name exists already in the shared file repository. If you still want to upload your file, please go back and use a new name. [[File:Mona_Lisa_one_two_one_two_this_is_just_a_test.jpg|thumb|center|Mona_Lisa_one_two_one_two_this_is_just_a_test.jpg]]'
Mar 16, 2020 10:29:29 AM com.bitplan.mediawiki.japi.MediaWikiApiImpl handleError
SCHWERWIEGEND: error: fileexists-shared-forbidden info: A file with this name exists already in the shared file repository. If you still want to upload your file, please go back and use a new name. [[File:Mona_Lisa_one_two_one_two_this_is_just_a_test.jpg|thumb|center|Mona_Lisa_one_two_one_two_this_is_just_a_test.jpg]]
Exception:error: fileexists-shared-forbidden info: A file with this name exists already in the shared file repository. If you still want to upload your file, please go back and use a new name. [[File:Mona_Lisa_one_two_one_two_this_is_just_a_test.jpg|thumb|center|Mona_Lisa_one_two_one_two_this_is_just_a_test.jpg]]

The Content of https://test.wikipedia.org/wiki/PictureTestPage is transferred to https://test2.wikipedia.org/wiki/PictureTestPage with a warning that the Mona Lisa file can not be transmitted.

Check setup and credentials

To check the setup and credentials for the wikis you'd like to use you might want to run:

./run --test -a

Example

./run --test -a
wf_wikipedia_org_test2.ini ✅:
	url=https://test2.wikipedia.org
	scriptPath=/w
	user=**
	e-mail=**
Mar 16, 2020 9:58:33 AM com.bitplan.mediawiki.japi.SSLWiki login
INFORMATION: https://test2.wikipedia.org/w/api.php?:Success
	version: MediaWiki 1.35.0-wmf.23✅
	sitename: Wikipedia
	    lang: en
wf_royals.ini ✅:
	url=http://royal-family.bitplan.com
	scriptPath=
	user=**
	e-mail=**
Mar 16, 2020 9:58:39 AM com.bitplan.mediawiki.japi.SSLWiki login
INFORMATION: http://royal-family.bitplan.com/api.php?:Success
	version: MediaWiki 1.33.2✅
	sitename: BITPlan royal-family Wiki
	    lang: en
wf_wiki.ini ✅:
	url=http://wiki.bitplan.com
	scriptPath=
	user=**
	e-mail=**
Mar 16, 2020 9:58:41 AM com.bitplan.mediawiki.japi.SSLWiki login
INFORMATION: http://wiki.bitplan.com/api.php?:Success
	version: MediaWiki 1.27.3✅
	sitename: BITPlan Wiki
	    lang: en
wf_mediawiki-japi.ini ✅:
	url=http://mediawiki-japi.bitplan.com
	scriptPath=
	user=**
	e-mail=**
Mar 16, 2020 9:58:45 AM com.bitplan.mediawiki.japi.SSLWiki login
INFORMATION: http://mediawiki-japi.bitplan.com/api.php?:Success
	version: MediaWiki 1.33.2✅
	sitename: BITPlan mediawiki-japi Wiki
	    lang: en
There are   0 problems

Usage

./run -h
Help
Mediawiki-Japi version 0.1.05
Please visit http://mediawiki-japi.bitplan.com for usage instructions
Mediawiki-Japi Version: 0.1.05

 github: https://github.com/WolfgangFahl/Mediawiki-Japi

  usage: java com.bitplan.mediawiki.japi.MediawikiMain
 --cookie WERT         : use given cookie for download
 -c (--check)          : check mode - tries access without writing to target
                         (Vorgabe: false)
 -d (--debug)          : debug
                         adds debugging output (Vorgabe: false)
 -h (--help)           : help
                         show this usage (Vorgabe: true)
 -i (--imageLimit) N   : the maximum number of images per page to push
                         (Vorgabe: 100)
 -l (--login)          : login to source wiki for access permission (Vorgabe:
                         false)
 -p (--pages) STRING[] : the pages to be transferred
 -s (--source) WERT    : the source wiki
 -t (--target) WERT    : the target wiki
 -u (--user) WERT      : activates credential mode
                         use -u -h to see options
                         see http://mediawiki-japi.bitplan.com/index.php/Command
                         Line
 -v (--version)        : showVersion
                         show current version if this switch is used (Vorgabe:
                         false)

Credential mode

Credential mode stores your wikis settings and credentials in an ini file in your client system's user's home directory. The password is encrypted which means its not visible. Anyone with access to the ini file can still decrypt it. Credential mode is activated by using the -u option. If you just want to see the usage it's sufficient to supply an invalid username like x

./run -h -u x
 -e (--email) WERT    : email
 -h (--help)          : help
                        show this usage (Vorgabe: true)
 -p (--password) WERT : password
 -u (--user) WERT     : username (Vorgabe: x)
 -w (--wikiId) WERT   : wiki id
 -y (--store)         : store without asking (Vorgabe: false)

Example

You might want to add the real information for

  • -u - User
  • -e - Email
  • --password - Password

where ** is shown as a placeholder

./run -w can4eve -u ** -e ** -l http://can4eve.bitplan.com -s '' -v 'MediaWiki 1.27.3' -y --password '**'
created/updated properties in /Users/wf/.mediawiki-japi/wf_can4eve.ini

Installation

./build