Пример #1
0
 def getSMW_WikiUser(wikiId="smw"):
     '''
     get semantic media wiki users for SemanticMediawiki.org and openresearch.org
     '''
     iniFile = WikiUser.iniFilePath(wikiId)
     wikiUser = None
     if not os.path.isfile(iniFile):
         wikiDict = None
         if wikiId == "smw":
             wikiDict = {
                 "wikiId": wikiId,
                 "url": "https://www.semantic-mediawiki.org",
                 "scriptPath": "/w",
                 "version": "MediaWiki 1.31.7"
             }
         if wikiId == "or":
             wikiDict = {
                 "wikiId": wikiId,
                 "url": "https://www.openresearch.org",
                 "scriptPath": "/mediawiki/",
                 "version": "MediaWiki 1.31.1"
             }
         if wikiDict is None:
             raise Exception("%s missing for wikiId %s" % (iniFile, wikiId))
         else:
             wikiUser = WikiUser.ofDict(wikiDict, lenient=True)
             if getpass.getuser() == "travis":
                 wikiUser.save()
     else:
         wikiUser = WikiUser.ofWikiId(wikiId, lenient=True)
     return wikiUser
Пример #2
0
 def getSMW_WikiUser(wikiId="cr"):
     '''
     get semantic media wiki users for SemanticMediawiki.org and openresearch.org
     '''
     iniFile = WikiUser.iniFilePath(wikiId)
     wikiUser = None
     if not os.path.isfile(iniFile):
         wikiDict = None
         if wikiId == "smwcopy":
             wikiDict = {
                 "wikiId": wikiId,
                 "email": "*****@*****.**",
                 "url": "http://smw.bitplan.com",
                 "scriptPath": "",
                 "version": "MediaWiki 1.35.0"
             }
         elif wikiId == "cr":
             wikiDict = {
                 "wikiId": wikiId,
                 "email": "*****@*****.**",
                 "url": "http://cr.bitplan.com",
                 "scriptPath": "",
                 "version": "MediaWiki 1.33.4"
             }
         elif wikiId == "smw":
             wikiDict = {
                 "wikiId": wikiId,
                 "email": "*****@*****.**",
                 "url": "https://www.semantic-mediawiki.org",
                 "scriptPath": "/w",
                 "version": "MediaWiki 1.31.7"
             }
         elif wikiId == "or":
             wikiDict = {
                 "wikiId": wikiId,
                 "email": "*****@*****.**",
                 "url": "https://www.openresearch.org",
                 "scriptPath": "/mediawiki/",
                 "version": "MediaWiki 1.31.1"
             }
         elif wikiId == 'wiki':
             wikiDict = {
                 "wikiId": wikiId,
                 "email": "*****@*****.**",
                 "url": "http://wiki.bitplan.com",
                 "scriptPath": "",
                 "version": "MediaWiki 1.27.3"
             }
         if wikiDict is None:
             raise Exception("%s missing for wikiId %s" % (iniFile, wikiId))
         else:
             wikiUser = WikiUser.ofDict(wikiDict, lenient=True)
             user = getpass.getuser()
             print("user is: %s" % user)
             # check the continuous integration users
             if user == "travis" or user == "runner":
                 wikiUser.save()
     else:
         wikiUser = WikiUser.ofWikiId(wikiId, lenient=True)
     return wikiUser
 def createWikiUser(wikiId="or"):
     wikiDict = {
         "wikiId": wikiId,
         "user": "",
         "email": "",
         "url": "https://www.openresearch.org",
         "scriptPath": "/mediawiki/",
         "version": "MediaWiki 1.31.1"
     }
     wikiUser = WikiUser.ofDict(wikiDict, lenient=True)
     wikiUser.save()
     return wikiUser
Пример #4
0
 def getSMW_WikiUser(wikiId="smw"):
     '''
     get semantic media wiki users for SemanticMediawiki.org and openresearch.org
     '''
     iniFile = WikiUser.iniFilePath(wikiId)
     wikiUser = None
     if not os.path.isfile(iniFile):
         wikiDict = None
         if wikiId == "smwcopy":
             wikiDict = {
                 "wikiId": wikiId,
                 "email": "*****@*****.**",
                 "url": "http://smw.bitplan.com",
                 "scriptPath": "",
                 "version": "MediaWiki 1.35.0"
             }
         if wikiId == "smw":
             wikiDict = {
                 "wikiId": wikiId,
                 "email": "*****@*****.**",
                 "url": "https://www.semantic-mediawiki.org",
                 "scriptPath": "/w",
                 "version": "MediaWiki 1.31.7"
             }
         if wikiId == "or":
             wikiDict = {
                 "wikiId": wikiId,
                 "email": "*****@*****.**",
                 "url": "https://www.openresearch.org",
                 "scriptPath": "/mediawiki/",
                 "version": "MediaWiki 1.31.1"
             }
         if wikiDict is None:
             raise Exception("%s missing for wikiId %s" % (iniFile, wikiId))
         else:
             wikiUser = WikiUser.ofDict(wikiDict, lenient=True)
             if TestWikiUser.inPublicCI():
                 wikiUser.save()
     else:
         wikiUser = WikiUser.ofWikiId(wikiId, lenient=True)
     return wikiUser
Пример #5
0
 def testCommandLine(self):
     '''
     test command line handling
     '''
     fd, path = tempfile.mkstemp(".ini")
     password = "******"
     try:
         if (fd):
             args = [
                 "--url", "http://wiki.doe.com", "-u", "john", "-e",
                 "*****@*****.**", "-w", "doe", "-s", "", "-v",
                 "MediaWiki 1.35.0", "-p", password, "-f", path, '-y'
             ]
             wikibot.wikiuser.main(args)
     finally:
         if self.debug:
             print(open(path, 'r').read())
         props = WikiUser.readPropertyFile(path)
         rUser = WikiUser.ofDict(props, encrypted=True)
         self.assertEqual(password, rUser.getPassword())
         os.remove(path)
Пример #6
0
 def checkIniFile(wikiId:str,save=None):
     '''
     check the ini file for the given wikiId
     
     Args:
         wikiId(str): the wiki id of the wiki to check
         save(bool): True if a new ini file should be created e.g. for test purposes
                     if not set save is True if we are running in a public continuous integration environment
     '''
     if save is None:
         save=Wiki.inPublicCI()
     iniFile = WikiUser.iniFilePath(wikiId)
     if not os.path.isfile(iniFile):
         wikiDict = None
         if wikiId == "wiki":
             wikiDict = {"wikiId": wikiId, "email": "*****@*****.**", "url": "https://wiki.bitplan.com",
                         "scriptPath": "/", "version": "MediaWiki 1.35.1"}
         if wikiDict is None:
             raise Exception(f"wikiId {wikiId} is not configured in $HOME.mediawiki-japi")
         else:
             wikiUser = WikiUser.ofDict(wikiDict, lenient=True)
             if save:
                 wikiUser.save()
         pass