def pause(): if arguments.pause_upgrade_loop: print "Testing paused." while True: testing.pause("Press ENTER to upgrade (to HEAD), CTRL-c to stop: ") for command in arguments.pause_upgrade_hook: subprocess.check_call(command, shell=True) repository.push("HEAD") instance.execute(["git", "fetch", "origin", "master"], cwd="critic") instance.upgrade_commit = "FETCH_HEAD" instance.upgrade() else: testing.pause("Testing paused. Press ENTER to continue: ")
def pause(failed_test=None): if arguments.pause_upgrade_loop \ or (failed_test and arguments.pause_upgrade_retry): print "Testing paused." while True: if failed_test and arguments.pause_upgrade_retry: testing.pause("Press ENTER to upgrade (to HEAD) and " "retry %s, CTRL-c to stop: " % os.path.basename(failed_test)) else: testing.pause("Press ENTER to upgrade (to HEAD), " "CTRL-c to stop: ") for command in arguments.pause_upgrade_hook: subprocess.check_call(command, shell=True) if isinstance(instance, testing.virtualbox.Instance): repository.push("HEAD") instance.execute(["git", "fetch", "origin", "master"], cwd="critic") instance.upgrade_commit = "FETCH_HEAD" instance.upgrade() if failed_test and arguments.pause_upgrade_retry: return "retry" else: testing.pause("Testing paused. Press ENTER to continue: ")
def pause(failed_test=None): if arguments.pause_upgrade_loop \ or (failed_test and arguments.pause_upgrade_retry): print "Testing paused." while True: if failed_test and arguments.pause_upgrade_retry: testing.pause("Press ENTER to upgrade (to HEAD) and " "retry %s, CTRL-c to stop: " % os.path.basename(failed_test)) else: testing.pause("Press ENTER to upgrade (to HEAD), " "CTRL-c to stop: ") for command in arguments.pause_upgrade_hook: subprocess.check_call(command, shell=True) repository.push("HEAD") instance.execute(["git", "fetch", "origin", "master"], cwd="critic") instance.upgrade_commit = "FETCH_HEAD" instance.upgrade() if failed_test and arguments.pause_upgrade_retry: return "retry" else: testing.pause("Testing paused. Press ENTER to continue: ")
def main(): parser = argparse.ArgumentParser( description="Critic testing framework: Quick install utility") parser.add_argument("--debug", help="Enable DEBUG level logging", action="store_true") parser.add_argument("--quiet", help="Disable INFO level logging", action="store_true") parser.add_argument("--commit", default="HEAD", help="Commit (symbolic ref or SHA-1) to test [default=HEAD]") parser.add_argument("--upgrade-from", help="Commit (symbolic ref or SHA-1) to install first and upgrade from") parser.add_argument("--vm-identifier", required=True, help="VirtualBox instance name or UUID") parser.add_argument("--vm-hostname", help="VirtualBox instance hostname [default=VM_IDENTIFIER]") parser.add_argument("--vm-snapshot", default="clean", help="VirtualBox snapshot (name or UUID) to upgrade [default=clean]") parser.add_argument("--vm-ssh-port", type=int, default=22, help="VirtualBox instance SSH port [default=22]") parser.add_argument("--git-daemon-port", type=int, help="Port to tell 'git daemon' to bind to") parser.add_argument("--interactive", "-i", action="store_true", help="Install interactively (without arguments)") arguments = parser.parse_args() logger = testing.configureLogging(arguments) logger.info("Critic testing framework: Quick install") tested_commit = subprocess.check_output( ["git", "rev-parse", "--verify", arguments.commit]).strip() if arguments.upgrade_from: install_commit = subprocess.check_output( ["git", "rev-parse", "--verify", arguments.upgrade_from]).strip() upgrade_commit = tested_commit else: install_commit = tested_commit upgrade_commit = None install_commit_description = subprocess.check_output( ["git", "log", "--oneline", "-1", install_commit]).strip() if upgrade_commit: upgrade_commit_description = subprocess.check_output( ["git", "log", "--oneline", "-1", upgrade_commit]).strip() else: upgrade_commit_description = None instance = testing.virtualbox.Instance( arguments, install_commit=(install_commit, install_commit_description), upgrade_commit=(upgrade_commit, upgrade_commit_description)) repository = testing.repository.Repository( arguments.git_daemon_port, install_commit, arguments.vm_hostname) mailbox = testing.mailbox.Mailbox() with repository, mailbox, instance: if not repository.export(): return instance.mailbox = mailbox instance.start() if arguments.interactive: print """ Note: To use the simple SMTP server built into the Critic testing framework, enter "host" as the SMTP host and "%d" as the SMTP port. Also note: The administrator user's password will be "testing" (password input doesn't work over this channel.)""" % mailbox.port instance.install(repository, quick=True, interactive=arguments.interactive) instance.upgrade(interactive=arguments.interactive) testing.pause("Press ENTER to stop VM: ") try: while True: mail = mailbox.pop() logger.info("Mail to <%s>:\n%s" % (mail.recipient, mail)) except testing.mailbox.MissingMail: pass
def main(): parser = argparse.ArgumentParser( description="Critic testing framework: instance upgrade utility") parser.add_argument("--debug", help="Enable DEBUG level logging", action="store_true") parser.add_argument("--quiet", help="Disable INFO level logging", action="store_true") parser.add_argument("--vm-identifier", help="VirtualBox instance name or UUID", required=True) parser.add_argument("--vm-hostname", help="VirtualBox instance hostname [default=VM_IDENTIFIER]") parser.add_argument("--vm-snapshot", help="VirtualBox snapshot (name or UUID) to upgrade", default="clean") parser.add_argument("--vm-ssh-port", help="VirtualBox instance SSH port [default=22]", type=int, default=22) parser.add_argument("--pause-before-upgrade", help="Pause before upgrading", action="store_true") parser.add_argument("--pause-after-upgrade", help="Pause after upgrading", action="store_true") parser.add_argument("--no-upgrade", action="store_true", help="Do not upgrade installed packages") parser.add_argument("--install", action="append", help="Install named package") parser.add_argument("--custom", action="store_true", help="Stop for custom maintenance, and always retake snapshot") parser.add_argument("--reboot", action="store_true", help="Reboot VM before retaking snapshot") arguments = parser.parse_args() logger = testing.configureLogging(arguments) logger.info("Critic Testing Framework: Instance Upgrade") instance = testing.virtualbox.Instance( identifier=arguments.vm_identifier, snapshot=arguments.vm_snapshot, hostname=arguments.vm_hostname, ssh_port=arguments.vm_ssh_port) with instance: instance.start() if not arguments.no_upgrade: logger.debug("Upgrading guest OS ...") update_output = instance.execute( ["sudo", "DEBIAN_FRONTEND=noninteractive", "apt-get", "-q", "-y", "update"]) logger.debug("Output from 'apt-get -q -y update':\n" + update_output) upgrade_output = instance.execute( ["sudo", "DEBIAN_FRONTEND=noninteractive", "apt-get", "-q", "-y", "upgrade"]) logger.debug("Output from 'apt-get -q -y upgrade':\n" + upgrade_output) retake_snapshot = False if "The following packages will be upgraded:" in upgrade_output.splitlines(): retake_snapshot = True if arguments.install: install_output = instance.execute( ["sudo", "DEBIAN_FRONTEND=noninteractive", "apt-get", "-q", "-y", "install"] + arguments.install) logger.debug("Output from 'apt-get -q -y install':\n" + install_output) retake_snapshot = True if arguments.custom: testing.pause() retake_snapshot = True if retake_snapshot: if arguments.reboot: instance.execute(["sudo", "reboot"]) logger.debug("Sleeping 10 seconds ...") time.sleep(10) instance.wait() logger.debug("Sleeping 10 seconds ...") time.sleep(10) logger.info("Rebooted VM: %s" % arguments.vm_identifier) logger.info("Upgraded guest OS") logger.debug("Retaking snapshot ...") instance.retake_snapshot(arguments.vm_snapshot) logger.info("Snapshot '%s' upgraded!" % arguments.vm_snapshot) else: logger.info("No packages upgraded in guest OS")
async def on_message(message): # We do not want the bot to reply to itself if message.author == client.user: return testing.on_ready() testing.ping() testing.eight_ball() testing.clear() testing.square() testing.bitcoin() testing.list_servers() testing.join() testing.leave() testing.play() testing.pause() testing.resume() testing.stop() testing.hot_posts() testing.rsearch() testing.timeout_error() testing.on_command_error() testing.value_error() testing.missing_argument_error() testing.r_meme() testing.meme_antispam() testing.g() testing.i() testing.testg() testing.delete()
def main(): parser = argparse.ArgumentParser( description="Critic testing framework: Quick install utility") parser.add_argument("--debug", help="Enable DEBUG level logging", action="store_true") parser.add_argument("--quiet", help="Disable INFO level logging", action="store_true") parser.add_argument( "--commit", default="HEAD", help="Commit (symbolic ref or SHA-1) to test [default=HEAD]") parser.add_argument( "--upgrade-from", help="Commit (symbolic ref or SHA-1) to install first and upgrade from" ) parser.add_argument("--vm-identifier", required=True, help="VirtualBox instance name or UUID") parser.add_argument( "--vm-hostname", help="VirtualBox instance hostname [default=VM_IDENTIFIER]") parser.add_argument( "--vm-snapshot", default="clean", help="VirtualBox snapshot (name or UUID) to upgrade [default=clean]") parser.add_argument("--vm-ssh-port", type=int, default=22, help="VirtualBox instance SSH port [default=22]") parser.add_argument("--git-daemon-port", type=int, help="Port to tell 'git daemon' to bind to") parser.add_argument("--interactive", "-i", action="store_true", help="Install interactively (without arguments)") arguments = parser.parse_args() logger = testing.configureLogging(arguments) logger.info("Critic testing framework: Quick install") tested_commit = subprocess.check_output( ["git", "rev-parse", "--verify", arguments.commit]).strip() if arguments.upgrade_from: install_commit = subprocess.check_output( ["git", "rev-parse", "--verify", arguments.upgrade_from]).strip() upgrade_commit = tested_commit else: install_commit = tested_commit upgrade_commit = None install_commit_description = subprocess.check_output( ["git", "log", "--oneline", "-1", install_commit]).strip() if upgrade_commit: upgrade_commit_description = subprocess.check_output( ["git", "log", "--oneline", "-1", upgrade_commit]).strip() else: upgrade_commit_description = None instance = testing.virtualbox.Instance( arguments, install_commit=(install_commit, install_commit_description), upgrade_commit=(upgrade_commit, upgrade_commit_description)) repository = testing.repository.Repository(arguments.git_daemon_port, install_commit, arguments.vm_hostname) mailbox = testing.mailbox.Mailbox() with repository, mailbox, instance: if not repository.export(): return instance.mailbox = mailbox instance.start() if arguments.interactive: print """ Note: To use the simple SMTP server built into the Critic testing framework, enter "host" as the SMTP host and "%d" as the SMTP port. Also note: The administrator user's password will be "testing" (password input doesn't work over this channel.)""" % mailbox.port instance.install(repository, quick=True, interactive=arguments.interactive) instance.upgrade(interactive=arguments.interactive) testing.pause("Press ENTER to stop VM: ") try: while True: mail = mailbox.pop() logger.info("Mail to <%s>:\n%s" % (mail.recipient, mail)) except testing.mailbox.MissingMail: pass