Part of lp.services.scripts.base View In Hierarchy
Known subclasses: lp.codehosting.scripts.modifiedbranches.ModifiedBranchesScript, lp.registry.scripts.closeaccount.CloseAccountScript, lp.registry.scripts.createbotaccount.CreateBotAccountScript, lp.registry.scripts.populate_distroseriesdiff.PopulateDistroSeriesDiff, lp.registry.scripts.suspendbotaccount.SuspendBotAccountScript, lp.services.scripts.base.LaunchpadCronScript, lp.services.scripts.tests.test_feature_controller.FakeScript, lp.soyuz.scripts.ftpmasterbase.SoyuzScript, lp.soyuz.scripts.ppareport.PPAReportScript, lp.translations.scripts.gettext_check_messages.GettextCheckMessages, lp.translations.scripts.remove_translations.RemoveTranslations, lp.translations.scripts.reupload_translations.ReuploadPackageTranslations, lp.translations.scripts.upload_translations.UploadPackageTranslations, lp.translations.utilities.translationmerger.MergeExistingPackagings, lp.translations.utilities.translationmerger.MessageSharingMerge
Inherit from this base class to simplify the setup work that your script needs to do.
"Give me convenience or give me death."
Method | __init__ | Construct new LaunchpadScript. |
Method | handle_options | Undocumented |
Method | name | Enable subclasses to override with command-line arguments. |
Method | dbuser | Enable subclasses to override with command-line arguments. |
Method | main | Define the meat of your script here. Must be defined. |
Method | add_my_options | Optionally customize this hook to define your own options. |
Method | login | Super-convenience method that avoids the import. |
Method | lockfilename | Return lockfilename. |
Method | lockfilepath | Undocumented |
Method | setup_lock | Create lockfile. |
Method | lock_or_die | Attempt to lock, and sys.exit(1) if the lock's already taken. |
Method | unlock | Release the lock. Do this before going home. |
Method | run | Actually run the script, executing zcml and initZopeless. |
Method | record_activity | Hook to record script activity. |
Method | lock_and_run | Call lock_or_die(), and then run() the script. |
Method | _init_zca | Initialize the ZCA, this can be overridden for testing purposes. |
Method | _init_db | Initialize the database transaction. |
Name is a short name for this script; it will be used to assemble a lock filename and to identify the logger object.
Use dbuser to specify the user to connect to the database; if not supplied a default will be used.
Specify test_args when you want to override sys.argv. This is useful in test scripts.
Parameters | logger | Use this logger, instead of initializing global logging. |
Raise LaunchpadScriptFailure if you encounter an error condition that makes it impossible for you to proceed; sys.exit(1) will be invoked in that situation.
Optionally customize this hook to define your own options.
This method should contain only a set of lines that follow the template:
- self.parser.add_option("-f", "--foo", dest="foo",
- default="foobar-makes-the-world-go-round", help="You are joking, right?")
May be overridden in targeted scripts in order to have more specific lockfilename.
Note that this will create a lockfile even if you don't actually use it. GlobalLock.__del__ is meant to clean it up though.
Say blocking=True if you want to block on the lock being available.
If you skip_delete, we won't try to delete the lock when it's freed. This is useful if you have moved the directory in which the lockfile resides.
Can be overridden for testing purposes.