3 # GNU MediaGoblin Selenium Automation
4 # Copyright (C) 2013 Emily O'Leary
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU Affero General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU Affero General Public License for more details.
16 # You should have received a copy of the GNU Affero General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 import ConfigParser, getopt, os, subprocess, sys
22 opts, args = getopt.getopt(sys.argv[1:], "w:d:", ["working=", "data="])
23 except getopt.GetoptError as err:
30 if o in ("-w", "--working"):
32 elif o in ("-d", "--data"):
35 print ("Unhandled option")
37 if (data == None or working == None):
38 print("Mandatory arguments not present.")
41 sys.path.append(os.path.join(working,"tests/util"))
42 from util import upload
45 config = ConfigParser.ConfigParser()
47 except ConfigParser.Error as err:
49 for user in config.options("users"):
50 ''' This loop creates new users from the config '''
51 newuser = config.get("users", user)
52 username,password,email = newuser.split(",")
53 subprocess.call([os.path.join(working, "mediagoblin/bin/gmg"),
54 "-cf", os.path.join(working,"mediagoblin/mediagoblin.ini"),
56 "--username", username,
57 "--password", password,
59 for media in config.options("media"):
60 ''' This loop uploads media from the config '''
61 newmedia = config.get("media", media)
62 username,password,uri,title,description,tags,license = newmedia.split(",")
63 mDict = {"username": username, "password": password,"uri": uri,
64 "title": title,"description": description,"tags": tags,
66 tUpload = upload.UploadFile()
69 for collection in config.options("collections"):
70 '''This loop creates collections from the config'''
71 newcollection = config.get("collection", collection)
72 username,password,mediatitle,collectiontitle,description,note = newmedia.split(",")
73 mDict = {"username": username, "password": password,
74 "mediatitle": mediatitle, "collectiontitle": collectiontitle,
75 "description": description, "note": note}
76 tCollection = collection.Collection()
77 tCollection.create_by_adding(mDict)