def _service(action):
    """
    Manages a local Papertrail service.

    Use the PT_ROOT environment variable to override the default installation path.
    """
    if action == 'start':
        if service.get_status() is not None:
            click.echo("PaperTrail already started")
        else:
            if service.start():
                click.echo('\nStarted PaperTrail')
    elif action == 'stop':
        if service.stop():
            click.echo('\nStopped PaperTrail')
        else:
            click.echo('PaperTrail is not running')
    elif action == 'restart':
        service.stop()
        service.start()
    elif action == 'status':
        status = service.get_status()
        if status is not None:
            click.echo("PaperTrail started (%s)" % str(status))
        else:
            click.echo("PaperTrail not started")
Beispiel #2
0
def main():

    logging.basicConfig(
        format = '[%(asctime)s] %(levelname)s: %(message)s',
        level = logging.INFO,
    )
    service.start(PopCon())
Beispiel #3
0
def main():
    import sys

    if len(sys.argv) < 2:
        sys.exit('Syntax: %s COMMAND' % sys.argv[0])

    cmd = sys.argv[1]
    sys.argv.remove(cmd)

    service = Service('example1', pid_dir='/tmp')

    if cmd == 'start':
        service.start()
    elif cmd == 'stop':
        service.stop()
        stop_function()
    elif cmd == 'restart':
        service.stop()
        stop_function()
        while service.is_running():
            time.sleep(0.1)
        service.start()
    elif cmd == 'status':
        if service.is_running():
            print "Service is running."
        else:
            print "Service is not running."
    else:
        sys.exit('Unknown command "%s".' % cmd)
Beispiel #4
0
def testall():
    service.start()

    service.on_battery_event(on_battery)
    service.on_rotation_event(on_rotation)

    service.identify()
    time.sleep(2)
    service.keyevent('KEYCODE_HOME')
    time.sleep(2)

    print 'wifi is', service.get_wifi_status()
    print 'disable', service.set_wifi_enabled(False)
    print 'wifi is', service.get_wifi_status()
    print 'enable', service.set_wifi_enabled(True)
    print 'wifi is', service.get_wifi_status()
    time.sleep(1)

    print 'set rotation'
    print service.set_rotation(1)
    time.sleep(1)
    print service.set_rotation(2)
    time.sleep(1)
    print service.set_rotation(3)
    time.sleep(1)
    print service.set_rotation(0)
    time.sleep(1)

    print 'display', service.get_display()
    time.sleep(1)

    print 'test type, please input'
    test_type()

    service.stop()
Beispiel #5
0
def add_or_update(conf, api, hosts):
    cl = _add(conf, api, hosts)

    # Add services
    for svc in conf['cluster']['services']:
        service.add_or_update(svc, cl, hosts, False)
        restart(cl, True)
        service.start(svc, cl)
Beispiel #6
0
def start(service):
    """
    Start a service and wait until it's running.
    """
    service.start()
    time.sleep(0.5)
    assert_running()
    return service
def add_or_update(conf, api, hosts):
    cl = _add(conf, api, hosts)

    # Add services
    for svc in conf['cluster']['services']:
        service.add_or_update(svc, cl, hosts, False)
        restart(cl, True)
        service.start(svc, cl)
Beispiel #8
0
def remove_cache():
    """Remove apt-cacher-ng caches, which get corrupted quite easily"""
    import service, time
    service.stop("apt-cacher-ng")
    time.sleep(2)
    sudo("rm -rf /var/cache/apt-cacher-ng/*")
    time.sleep(2)
    service.start("apt-cacher-ng")
Beispiel #9
0
def main():
    # Create the root object at /easymon/ and build the full tree on it
    easymon = Easymon()
    build(easymon, tree, 'CMS ConditionDB EasyMon')

    # Also build the online tree independently at /easymon/online/
    easymon.online = Easymon()
    build(easymon.online, onlineTree, 'CMS ConditionDB Online EasyMon')

    service.start(easymon)
Beispiel #10
0
def main():
    # Create the root object at /easymon/ and build the full tree on it
    easymon = Easymon()
    build(easymon, tree, 'CMS ConditionDB EasyMon')

    # Also build the online tree independently at /easymon/online/
    easymon.online = Easymon()
    build(easymon.online, onlineTree, 'CMS ConditionDB Online EasyMon')

    service.start(easymon)
Beispiel #11
0
def main():
    service.start()

    root = tk.Tk()
    root.resizable(0, 0)
    root.title('STF Input')
    sv = tk.StringVar()

    if sys.platform == 'win32':
        backspace = '\x08'
    else:
        backspace = '\x7f'

    def send(event, sv=sv):
        char = event.char
        if not char:
            return
        text = sv.get()
        if char == '\r' and text:  # use <Return> to input
            service.type(text)
            sv.set('')
            return
        if char == backspace and text:  #  use <Backspace> to delete, <Del> not avaialable.
            sv.set('')
            return
        if char == '\x16':  # skip <Ctrl-V>
            service.keyboard(char)
            sv.set('')
            return 'break'
        if char in keycode.KEYBOARD_KEYS or char in keycode.CTRLED_KEYS:
            service.keyboard(char)

    entry = tk.Entry(root, textvariable=sv)
    entry.pack()
    entry.focus_set()
    entry.bind('<Key>', send)

    state = [1]

    def toggle(root=root, entry=entry):
        if state[0] == 0:
            root.deiconify()
            entry.focus_set()
            state[0] = 1
        else:
            root.withdraw()
            state[0] = 0

    register_hotkey(root, 'Ctrl-Alt-Z', toggle)  # not very well with IME

    try:
        root.mainloop()
    finally:
        service.stop()
Beispiel #12
0
def main():
    service.start()

    root = tk.Tk()
    root.resizable(0, 0)
    root.title('STF Input')
    sv = tk.StringVar()

    if sys.platform == 'win32':
        backspace = '\x08'
    else:
        backspace = '\x7f'

    def send(event, sv=sv):
        char = event.char
        if not char:
            return
        text = sv.get()
        if char == '\r' and text: # use <Return> to input
            service.type(text)
            sv.set('')
            return
        if char == backspace and text: #  use <Backspace> to delete, <Del> not avaialable.
            sv.set('')
            return
        if char == '\x16': # skip <Ctrl-V>
            service.keyboard(char)
            sv.set('')
            return 'break'
        if char in keycode.KEYBOARD_KEYS or char in keycode.CTRLED_KEYS:
            service.keyboard(char)

    entry = tk.Entry(root, textvariable=sv)
    entry.pack()
    entry.focus_set()
    entry.bind('<Key>', send)

    state = [1]
    def toggle(root=root, entry=entry):
        if state[0] == 0:
            root.deiconify()
            entry.focus_set()
            state[0] = 1
        else:
            root.withdraw()
            state[0] = 0

    register_hotkey(root, 'Ctrl-Alt-Z', toggle) # not very well with IME

    try:
        root.mainloop()
    finally:
        service.stop()
Beispiel #13
0
def start(service):
    """
    Start a service and wait until it's running.
    """
    ok(service.start(block=TIMEOUT))
    assert_running()
    return service
Beispiel #14
0
def startup():
    
    define(r'port', 80, int, r'Server listen port')
    define(r'service', False, bool, r'Open Scheduled Tasks')
    
    options.parse_command_line()
    
    if(config.Static.Debug):
        options.parse_command_line([__file__, r'--service=true', r'--logging=debug'])
    
    settings = {
                r'handlers': router.urls,
                r'static_path': r'static',
                r'template_loader': Jinja2Loader(r'view'),
                r'debug': config.Static.Debug,
                r'gzip': config.Static.GZip,
                r'cookie_secret': config.Static.Secret,
                }
    
    sockets = bind_sockets(options.port)
    
    task_id = 0
    
    if(platform.system() == r'Linux'):
        task_id = fork_processes(cpu_count())
    
    server = HTTPServer(Application(**settings))
    
    server.add_sockets(sockets)
    
    if(task_id == 0 and options.service):
        service.start()
    
    signal.signal(signal.SIGINT, lambda *args : shutdown(server))
    signal.signal(signal.SIGTERM, lambda *args : shutdown(server))
    
    app_log.info(r'Startup http server No.{0}'.format(task_id))
    
    IOLoop.instance().start()
Beispiel #15
0
    def test_start_started_build(self):
        build = self.new_leased_build(id=1)
        lease_key = build.lease_key
        url = 'http://localhost/'

        service.start(1, lease_key, url)
        service.start(1, lease_key, url)
        service.start(1, lease_key, url + '1')
Beispiel #16
0
  def test_start_started_build(self):
    self.lease()
    build_id = self.test_build.key.id()
    lease_key = self.test_build.lease_key
    url = 'http://localhost/'

    service.start(build_id, lease_key, url)
    service.start(build_id, lease_key, url)
    service.start(build_id, lease_key, url + '1')
Beispiel #17
0
def allp(kc):
    for x in kc:

        match = re.findall("[0-9]+\.[0-9a-z]+",
                           BeautifulSoup(x['status']['content']).get_text())
        usr = x['status']['account']['username']
        mastadon.status_post(
            "@" + x['status']['account']['username'] + " " +
            "Recived Your Request Proceesing The Information ",
            visibility='direct')
        try:
            for xp in match:
                arxiv_link = "http://export.arxiv.org/api/query?id_list=" + xp
                print("-----------------------")

                text_str = BeautifulSoup(libreq.urlopen(
                    arxiv_link).read()).find('summary').get_text()

                regex = r"\$[-\\\"#\/@^( ),.;:<>{}\[\]`'+=~|!?_a-zA-Z0-9]*\*"
                regex2 = r"\$"
                matches2 = re.finditer(regex2, text_str, re.MULTILINE)
                counter_to_check_even_do_symbols = 0
                for y in matches2:
                    counter_to_check_even_do_symbols += 1
                    if counter_to_check_even_do_symbols % 2 == 0:
                        text_str = text_str[:y.start(
                        )] + "*" + text_str[y.start() + 1:]
                text_str = text_str.replace("\n", " ")
                matches = re.finditer(regex, text_str, re.MULTILINE)
                for on in matches:
                    text_str = text_str.replace(str(on.group()), "")

                abs_wo_punc = re.sub("[^a-zA-Z0-9;:!?.,]", " ", text_str)

                arrs = service.start(abs_wo_punc)

                op = ""
                for np in arrs:
                    npp = "http://arxiv.org/abs/" + str(
                        np[1]) + "   " + "Score " + str(np[3]) + "\n"
                    op = op + npp
                mastadon.status_post("@" + usr + " " + op, visibility='direct')
        except:
            mastadon.status_post("@" + usr + " " + "Bad-Request for " + xp,
                                 visibility='direct')

        mastadon.notifications_dismiss(x['id'])
    sta()
Beispiel #18
0
def main():
    service.start(Browser())
Beispiel #19
0
def main():
    service.start(Admin())
Beispiel #20
0
def main():
    service.start(Docs())
Beispiel #21
0
 def start(self, request):
   """Marks a build as started."""
   build = service.start(request.id, request.lease_key, url=request.url)
   return build_to_response_message(build)
Beispiel #22
0
 def test_start_non_leased_build(self):
     self.classic_build(id=1).put()
     with self.assertRaises(errors.LeaseExpiredError):
         service.start(1, 42, None)
Beispiel #23
0
def main():
    service.start(ShibbolethTest())
Beispiel #24
0
#!/usr/bin/env python3
# -*- encoding: utf-8 -*-

# @Time    : 2018/11/28 14:38
# @Author  : YANHAI

from service import start

if __name__ == "__main__":
    start()
Beispiel #25
0
 def test_start_non_leased_build(self):
   self.test_build.put()
   with self.assertRaises(errors.LeaseExpiredError):
     service.start(self.test_build.key.id(), 42)
Beispiel #26
0
def main():
    service.start(Frontier())
Beispiel #27
0
 def test_start_completed_build(self):
   self.test_build.status = model.BuildStatus.COMPLETED
   self.test_build.result = model.BuildResult.SUCCESS
   self.test_build.put()
   with self.assertRaises(errors.BuildIsCompletedError):
     service.start(self.test_build.key.id(), 42)
Beispiel #28
0
def main():
    service.start(UploadGTServer())
Beispiel #29
0
def main():
    service.start(Admin())
def main():
	service.start(CondDBPayloadInspector())
Beispiel #31
0
 def start(self, request):
     """Marks a build as started."""
     build = service.start(request.id, request.lease_key, url=request.url)
     return build_to_response_message(build)
Beispiel #32
0
def main():
    service.start(ServiceTemplate())
Beispiel #33
0
 def start(self, build, url=None, lease_key=None):
     return service.start(build.key.id(), lease_key or build.lease_key, url)
Beispiel #34
0
def main():
    service.start(DropBox())
Beispiel #35
0
def main():
    service.start(Libs())
Beispiel #36
0
def setup_server4(hostname=None, domain=None, pc="1", forge_modules=["puppetlabs/stdlib", "puppetlabs/concat", "puppetlabs/firewall", "puppetlabs/apt"]):
    """Setup Puppet 4 server"""
    import package, util, git, service

    # Local files to copy over
    basedir = "/etc/puppetlabs"
    local_master_conf = "files/puppet-master.conf"
    remote_master_conf = basedir+"/puppet/puppet.conf"
    local_hiera_yaml = "files/hiera.yaml"
    remote_hiera_yaml = basedir+"/code/hiera.yaml"
    local_fileserver_conf = "files/fileserver.conf"
    remote_fileserver_conf = basedir+"/puppet/fileserver.conf"
    local_environments = "files/environments"
    remote_codedir = basedir+"/code"
    local_gitignore = "files/gitignore"
    remote_gitignore = basedir+"/.gitignore"
    modules_dir = basedir+"/code/environments/production/modules"

    # Verify that all the local files are in place
    try:
        open(local_master_conf)
        open(local_hiera_yaml)
    except IOError:
        print "ERROR: some local config files were missing!"
        sys.exit(1)

    # Autodetect hostname and domain from env.host, if they're not overridden
    # with method parameters
    if not hostname:
        hostname = util.get_hostname()
    if not domain:
        domain = util.get_domain()

    # Ensure that clock is correct before doing anything else, like creating SSL 
    # certificates.
    util.set_clock()

    # Start the install
    install_puppetlabs_release_package(pc)
    package.install("puppetserver")
    util.put_and_chown(local_master_conf, remote_master_conf)
    util.put_and_chown(local_hiera_yaml, remote_hiera_yaml)
    util.put_and_chown(local_fileserver_conf, remote_fileserver_conf)
    util.put_and_chown(local_gitignore, remote_gitignore)
    util.add_to_path("/opt/puppetlabs/bin")
    util.set_hostname(hostname + "." + domain)
    # "facter fqdn" return a silly name on EC2 without this
    util.add_host_entry("127.0.1.1", hostname, domain)

    # Copy over template environments
    util.put_and_chown(local_environments, remote_codedir)

    # Add modules from Puppet Forge. These should in my experience be limited to
    # those which provide new types and providers. In particular puppetlabs'
    # modules which control some daemon (puppetdb, postgresql, mysql) are
    # extremely complex, very prone to breakage and nasty to debug. 
    for module in forge_modules:
        add_forge_module(module)

    # Git setup
    git.install()
    git.init(basedir)
    if not exists(modules_dir):
        sudo("mkdir "+modules_dir)
    git.init(modules_dir)
    git.add_submodules(basedir=modules_dir)
    git.add_all(basedir)
    git.commit(basedir, "Initial commit")

    # Link hieradata and manifests from production to testing. This keeps the
    # testing environment identical to the production environment. The modules
    # directory in testing is separate and may (or may not) contain modules that
    # override or complement those in production.
    util.symlink(remote_codedir+"/environments/production/hieradata", remote_codedir+"/environments/testing/hieradata")
    util.symlink(remote_codedir+"/environments/production/manifests", remote_codedir+"/environments/testing/manifests")

    # Start puppetserver to generate the CA and server certificates/keys
    service.start("puppetserver")
    run_agent(noop="False")
Beispiel #37
0
def main():
    service.start(AjaxApp())
Beispiel #38
0
 def test_start_without_lease_key(self):
     with self.assertRaises(errors.InvalidInputError):
         service.start(1, None, None)
Beispiel #39
0
import signal

import cerver

import db
import service
from todo import todo_config
import version

if __name__ == "__main__":
	signal.signal (signal.SIGINT, service.end)
	signal.signal (signal.SIGTERM, service.end)
	signal.signal (signal.SIGPIPE, signal.SIG_IGN)

	cerver.cerver_init ()

	cerver.cerver_version_print_full ()

	cerver.pycerver_version_print_full ()

	version.todo_version_print_full ()

	todo_config ()

	if (db.todo_mongo_init ()):
		service.start ()
Beispiel #40
0
 def test_start_completed_build(self):
     self.classic_build(id=1, status=common_pb2.SUCCESS).put()
     with self.assertRaises(errors.BuildIsCompletedError):
         service.start(1, 42, None)
Beispiel #41
0
 def test_start_without_lease_key(self):
   with self.assertRaises(errors.InvalidInputError):
     service.start(1, None)
Beispiel #42
0
def main():
    service.start(Logs())
Beispiel #43
0
 def start(self, url=None, lease_key=None):
   self.test_build = service.start(
     self.test_build.key.id(),
     lease_key or self.test_build.lease_key,
     url=url)
Beispiel #44
0
def main():
	service.start(UploadGTServer())
Beispiel #45
0
def main():
    service.start(Server())
Beispiel #46
0
def main():
    start()
Beispiel #47
0
def main():
    service.start(AjaxApp())
Beispiel #48
0
def main():
    service.start(Browser())
Beispiel #49
0
def main():
    service.start(DropBox())
Beispiel #50
0
def main():
    service.start(Libs())
Beispiel #51
0
def main():
    service.start(SessionTest())
Beispiel #52
0
def main():
    service.start(Server())
Beispiel #53
0
def main():
	service.start(SessionTest())