38
37
from storm.store import Store
40
from canonical.lp import initZopeless
42
39
from lp.app.interfaces.launchpad import ILaunchpadCelebrities
43
from canonical.launchpad.scripts import execute_zcml_for_scripts
44
from canonical.launchpad.scripts.logger import logger, logger_options
45
40
from canonical.launchpad.webapp.interfaces import (
46
41
IStoreSelector, MAIN_STORE, MASTER_FLAVOR, SLAVE_FLAVOR)
49
44
from lp.registry.interfaces.person import IPersonSet
50
45
from lp.registry.interfaces.series import SeriesStatus
51
46
from lp.registry.model.codeofconduct import SignedCodeOfConduct
47
from lp.services.scripts.base import LaunchpadScript
52
48
from lp.soyuz.enums import SourcePackageFormat
53
49
from lp.soyuz.interfaces.component import IComponentSet
54
50
from lp.soyuz.interfaces.processor import IProcessorFamilySet
109
105
% current_config)
112
def parse_args(arguments):
113
"""Parse command-line arguments.
115
:return: (options, args, logger)
117
parser = OptionParser(
118
description="Set up fresh Ubuntu series and %s identity." % user_name)
119
parser.add_option('-f', '--force', action='store_true', dest='force',
120
help="DANGEROUS: run even if the database looks production-like.")
121
parser.add_option('-e', '--email', action='store', dest='email',
122
default=default_email,
124
"Email address to use for %s. Should match your GPG key."
127
logger_options(parser)
129
options, args = parser.parse_args(arguments)
131
return options, args, logger(options)
134
108
def get_person_set():
135
109
"""Return `IPersonSet` utility."""
136
110
return getUtility(IPersonSet)
374
348
"main restricted universe multiverse\n")
378
options, args, log = parse_args(argv[1:])
380
execute_zcml_for_scripts()
381
txn = initZopeless(dbuser='launchpad')
383
check_preconditions(options.force)
385
ubuntu = getUtility(ILaunchpadCelebrities).ubuntu
386
clean_up(ubuntu, log)
388
# Use Hoary as the root, as Breezy and Grumpy are broken.
389
populate(ubuntu, 'hoary', 'ubuntu-team', options, log)
391
admin = get_person_set().getByName('name16')
392
person = create_ppa_user(user_name, options, admin, log)
394
create_ppa(ubuntu, person, 'test-ppa')
400
Now start your local Launchpad with "make run_codehosting" and log
401
into https://launchpad.dev/ as "%(email)s" with "test" as the
403
Your user name will be %(user_name)s."""
405
'email': options.email,
406
'user_name': user_name,
351
class SoyuzSampledataSetup(LaunchpadScript):
353
description = "Set up fresh Ubuntu series and %s identity." % user_name
355
def add_my_options(self):
356
self.parser.add_option(
357
'-f', '--force', action='store_true', dest='force',
358
help="DANGEROUS: run even if the database looks production-like.")
359
self.parser.add_option(
360
'-e', '--email', action='store', dest='email',
361
default=default_email,
363
"Email address to use for %s. Should match your GPG key."
367
check_preconditions(self.options.force)
369
ubuntu = getUtility(ILaunchpadCelebrities).ubuntu
370
clean_up(ubuntu, self.logger)
372
# Use Hoary as the root, as Breezy and Grumpy are broken.
373
populate(ubuntu, 'hoary', 'ubuntu-team', self.options, self.logger)
375
admin = get_person_set().getByName('name16')
376
person = create_ppa_user(user_name, self.options, admin, self.logger)
378
create_ppa(ubuntu, person, 'test-ppa')
381
self.logger.info("Done.")
384
Now start your local Launchpad with "make run_codehosting" and log
385
into https://launchpad.dev/ as "%(email)s" with "test" as the
387
Your user name will be %(user_name)s."""
389
'email': self.options.email,
390
'user_name': user_name,
410
394
if __name__ == "__main__":
395
SoyuzSampledataSetup('soyuz-sampledata-setup').lock_and_run()