Beispiel #1
0
def main():

    parser = argparse.ArgumentParser()
    parser.add_argument("-i","--install", help="Install self as a right click option",action="store_true")
    parser.add_argument("-p","--password",type=str,help="A valid password for an OpenSubtitles user",required=True)
    parser.add_argument("-u","--user", type=str, help="A valid email for an OpenSubtitles user",required=True)
    parser.add_argument("-f","--file", type=str, help="Path to a media file")
    parser.add_argument("-l", "--language", type=str,default="eng" ,help="Language of desired subtitles, NOTE: if used with install flag will install for the specifid language. default is English")
    args = parser.parse_args()

    if not args.install and not args.file:
        print "Argument Error: you must either specify --file or --install"
        return False

    if not check_language(args.language):
        return False

    if args.install:
        install(args)
        Messagebox("Installed", "Installed Subgetty on your computer with these parameters password={} user={} language={}".format(args.password ,args.user,args.language), 1)
        return True

    if not os.path.exists(args.file):
        print "Error Media File Doesnt exists"
        return False


    osm = OpenSubtitlesManager(args.user, args.password, args.file, language=args.language)
    if osm.run():
        Messagebox("Found!", "Subtitles were found and downloaded", 1)
    else:
        Messagebox("Check STDOUT for Error Message", "No subtitles found", 1)
def main():
    print "Static HTML file browser for Dropbox"

    parser = argparse.ArgumentParser()

    parser.add_argument("location",
                        help="path to the Public folder of your Dropbox folder.")

    group = parser.add_mutually_exclusive_group()
    group.add_argument("-i", "--install",
                       action="store_true",
                       help="prepares your Dropbox folder by copying icons to the specified directory.\
                             This directory can be set up in config.py configuration file.")
    group.add_argument("--clean",
                       action="store_true",
                       help="cleans your Dropbox directory by deleting index.html files.")

    args = parser.parse_args()

    if args.install:
        utils.install(args.location)
        exit(0)

    if args.clean:
        utils.cleanup(args.location)
        exit(0)

    create_index_html(args.location)
Beispiel #3
0
def install():
    utils.juju_log('INFO', 'Begin install hook.')
    utils.enable_pocket('multiverse')
    utils.configure_source()
    utils.install('radosgw', 'libapache2-mod-fastcgi', 'apache2', 'ntp')
    os.makedirs(NSS_DIR)
    utils.juju_log('INFO', 'End install hook.')
def main():
    print("Static HTML file browser for Dropbox")

    parser = argparse.ArgumentParser()

    parser.add_argument(
        "location", help="path to the Public folder of your Dropbox folder.")

    group = parser.add_mutually_exclusive_group()
    group.add_argument(
        "-i",
        "--install",
        action="store_true",
        help=
        "prepares your Dropbox folder by copying icons to the specified directory.\
                             This directory can be set up in config.py configuration file."
    )
    group.add_argument(
        "--clean",
        action="store_true",
        help="cleans your Dropbox directory by deleting index.html files.")

    args = parser.parse_args()

    if args.install:
        utils.install(args.location)
        exit(0)

    if args.clean:
        utils.cleanup(args.location)
        exit(0)

    create_index_html(args.location)
Beispiel #5
0
def setup():
	if not is_installed("git"):
		install("git")

	if get_config("user.name") == None:
		set_config("user.name", prompt("Enter Git username:"******"user.email") == None:
		set_config("user.email", prompt("Enter Git email:"))
Beispiel #6
0
def setup():
	if not is_installed("vim"):
		install("vim")

	if not exists("~/.vim"):
		github.clone("vimfiles", "~/.vim")

	if not exists("~/.vimrc"):
		run("ln ~/.vim/vimrc ~/.vimrc")
Beispiel #7
0
def install():
    utils.juju_log('INFO', 'Begin install hook.')
    utils.enable_pocket('multiverse')
    utils.configure_source()
    utils.install('radosgw',
                  'libapache2-mod-fastcgi',
                  'apache2',
                  'ntp')
    os.makedirs(NSS_DIR)
    utils.juju_log('INFO', 'End install hook.')
Beispiel #8
0
def radosgw_relation():
    utils.juju_log('INFO', 'Begin radosgw-relation hook.')

    utils.install('radosgw')  # Install radosgw for admin tools

    if ceph.is_quorum():
        utils.juju_log('INFO',
                       'mon cluster in quorum - \
                        providing radosgw with keys')
        utils.relation_set(radosgw_key=ceph.get_radosgw_key(),
                           auth=utils.config_get('auth-supported'))
    else:
        utils.juju_log('INFO',
                       'mon cluster not in quorum - deferring key provision')

    utils.juju_log('INFO', 'End radosgw-relation hook.')
    def setUp(self):
        admin_opts = {}
        fields = {'name': models.CharField(max_length=255)}
        self.dynamic_model = create_model('DynamicModel', fields=fields, app_label='context_admin', admin_opts={})

        fields = {  'name': models.CharField(max_length=255),
                    'dynamic_model': models.ForeignKey(self.dynamic_model)
                    }

        self.dynamic_inner_model = create_model('DynamicInnerModel', fields=fields, app_label='context_admin', admin_opts={})
        

        install(self.dynamic_model)
        install(self.dynamic_inner_model)

        instance = self.dynamic_model()
        instance.save()
Beispiel #10
0
def main():
    if len(sys.argv) == 1:
        utils.install()

    report = Report(sys.argv[1])

    utils.check_config()

    info = utils.get_task_info(report.data)
    target = utils.get_deliver_dir(info)

    msg = "\nDo you want to deliver test result to \n{0}".format(target)
    utils.confirm(msg)

    report.update_issue(info)

    report.deliver_result(target)

    report.xlsx_update()

    utils.tmp_print_info(report)
Beispiel #11
0
    def setUp(self):
        admin_opts = {}
        fields = {'name': models.CharField(max_length=255)}
        self.dynamic_model = create_model('DynamicModel',
                                          fields=fields,
                                          app_label='context_admin',
                                          admin_opts={})

        fields = {
            'name': models.CharField(max_length=255),
            'dynamic_model': models.ForeignKey(self.dynamic_model)
        }

        self.dynamic_inner_model = create_model('DynamicInnerModel',
                                                fields=fields,
                                                app_label='context_admin',
                                                admin_opts={})

        install(self.dynamic_model)
        install(self.dynamic_inner_model)

        instance = self.dynamic_model()
        instance.save()
def install():
    ceph_dir = "/etc/ceph"
    if not os.path.isdir(ceph_dir):
        os.mkdir(ceph_dir)
    utils.install('ceph-common')
    ('https://dl.dropboxusercontent.com/u/4780737/pywebkitgtk.zip',
     'pywebkitgtk.zip', SITE_PACKAGES),
]

FILES = [
    # Unneeded. Serves only as an example.
    #('https://dl.dropboxusercontent.com/u/4780737/gtkspell.pyd',
    #      os.path.join(DRIVE_C_REAL, 'Python27', 'Lib', 'site-packages', 'gtkspell.pyd'))
]

print HELP

for url, filename in INSTALLERS:
    path = os.path.join(INSTALLERS_DIR, filename)
    fetch(url, path)
    install(path, use_wine=IS_LINUX)

for url, filename, dest in TARBALLS:
    path = os.path.join(INSTALLERS_DIR, filename)
    fetch(url, path)
    cmd = ['wine'] if IS_LINUX else []
    assert path.endswith('.zip'), path
    cmd.extend([SEVEN_ZIP, 'x', '-o' + dest, path])
    run(cmd)

for url, dest in FILES:
    fetch(url, dest)

# TODO: Remove once pygtkspellcheck lists its dependencies.
run(PYTHON + ['-m', 'pip', 'install', 'pyenchant==1.6.8'])
Beispiel #14
0
    ('https://www.dropbox.com/s/kljn5gsxm1fxa10/aspell-dicts.zip?dl=1',
     'aspell-dicts.zip', os.path.join(SITE_PACKAGES,
                                      'gnome/lib/aspell-0.60/')),
]

FILES = []

print(HELP)

# For Python >= 3.5 set Windows Version to at least Windows 7.
# run(['winecfg'])

for url, filename in INSTALLERS:
    path = os.path.join(INSTALLERS_DIR, filename)
    fetch(url, path)
    install(path, use_wine=USE_WINE)

for url, filename, dest in TARBALLS:
    path = os.path.join(INSTALLERS_DIR, filename)
    fetch(url, path)
    cmd = ['wine'] if USE_WINE else []
    assert path.endswith('.zip'), path
    cmd.extend([SEVEN_ZIP, 'x', '-o' + dest, path])
    run(cmd)

for url, dest in FILES:
    fetch(url, dest)

run(PYTHON + ['-m', 'pip', 'install', '-r', REQUIREMENTS])

if IS_WIN:
Beispiel #15
0
def install(row, config, logger, lock):
    """
    Основной скрипт, выполняющий все необходимые настройки на сервере
    :param row:
    :param config:
    :param logger:
    :param lock:
    :return:
    """
    install_path = '{protocol}://{domain}'.format(protocol=config.get(
        'config', 'protocol'),
                                                  domain=row.get('domain'))

    url = utils.install(config, install_path)

    with requests.session() as s:
        s.get(url)

        payload, params = payloads.get_session(config)
        r = s.post(url, data=payload, params=params)

        with lock:
            logger.info(
                '{status} - {url} - %s'.format(status=r.status_code, url=url),
                params)

        data = payloads.data(url)

        for index, datum in enumerate(data):
            payload = datum.get('payload')
            params = datum.get('params')
            r = s.post(url, data=payload, params=params)

            with lock:
                logger.info(
                    '{status} - {url} - %s'.format(status=r.status_code,
                                                   url=url), params)
        """
        Шаги обновления бд, на всякий случай прохожу все 3,
        если в этом нет необходимости можно сократить сразу до 3 шага
        """
        for index in range(3):
            params = {'controller': 'update', 'step': index + 1}

            r = s.get(url, params=params)

            with lock:
                logger.info(
                    '{status} - {url} - %s'.format(status=r.status_code,
                                                   url=url), params)

            if index + 1 == 3:
                soup = BeautifulSoup(r.content, 'html.parser')
                links = soup.find_all(href=True)
                link = next(
                    link.get('href') for link in links
                    if re.search(r'\.sql', link.get('href')))

                if link:
                    query = parse_qs(urlparse(link).query)

                    params.update({'part': query.get('part').pop()})

                    r = s.get(url, params=params)

                    with lock:
                        logger.info(
                            '{status} - {url} - %s'.format(
                                status=r.status_code, url=url), params)
                else:
                    with lock:
                        logger.warning(
                            'No sql links - {url} - %s'.format(url=url),
                            params)
Beispiel #16
0
def install_ganglia():
    install("ganglia-webfrontend", "gmetad")
    install("ganglia-monitor")
                            and tag2name[label_ids[i][j]] != "[SEP]"):
                        temp_y_true.append(tag2name[label_ids[i][j]])
                        temp_y_pred.append(tag2name[logits[i][j]])
                else:
                    break

            y_true.append(temp_y_true)
            y_pred.append(temp_y_pred)

    print("Test Set F1 Score: %f" % (f1_score(y_true, y_pred)))
    print('--------------------')


if __name__ == '__main__':

    install('transformers')
    install('tqdm')
    install('seqeval')

    import subprocess
    import sys
    from transformers import RobertaConfig, RobertaForTokenClassification, AdamW
    from tqdm import tqdm, trange
    from seqeval.metrics import f1_score

    parser = argparse.ArgumentParser()

    parser.add_argument('--batch-size',
                        type=int,
                        default=32,
                        metavar='N',
Beispiel #18
0
def install():
    utils.juju_log('INFO', 'Begin install hook.')
    utils.configure_source()
    utils.install('ceph', 'gdisk', 'ntp')
    install_upstart_scripts()
    utils.juju_log('INFO', 'End install hook.')
Beispiel #19
0
def enable_https(port_maps, namespace, cert, key, ca_cert=None):
    '''
    For a given number of port mappings, configures apache2
    HTTPs local reverse proxying using certficates and keys provided in
    either configuration data (preferred) or relation data.  Assumes ports
    are not in use (calling charm should ensure that).

    port_maps: dict: external to internal port mappings
    namespace: str: name of charm
    '''
    def _write_if_changed(path, new_content):
        content = None
        if os.path.exists(path):
            with open(path, 'r') as f:
                content = f.read().strip()
        if content != new_content:
            with open(path, 'w') as f:
                f.write(new_content)
            return True
        else:
            return False

    juju_log('INFO', "Enabling HTTPS for port mappings: {}".format(port_maps))
    http_restart = False

    if cert:
        cert = b64decode(cert)
    if key:
        key = b64decode(key)
    if ca_cert:
        ca_cert = b64decode(ca_cert)

    if not cert and not key:
        juju_log('ERROR',
                 "Expected but could not find SSL certificate data, not "
                 "configuring HTTPS!")
        return False

    install('apache2')
    if RELOAD_CHECK in subprocess.check_output(['a2enmod', 'ssl',
                                                'proxy', 'proxy_http']):
        http_restart = True

    ssl_dir = os.path.join('/etc/apache2/ssl', namespace)
    if not os.path.exists(ssl_dir):
        os.makedirs(ssl_dir)

    if (_write_if_changed(os.path.join(ssl_dir, 'cert'), cert)):
        http_restart = True
    if (_write_if_changed(os.path.join(ssl_dir, 'key'), key)):
        http_restart = True
    os.chmod(os.path.join(ssl_dir, 'key'), 0600)

    install_ca_cert(ca_cert)

    sites_dir = '/etc/apache2/sites-available'
    for ext_port, int_port in port_maps.items():
        juju_log('INFO',
                 'Creating apache2 reverse proxy vhost'
                 ' for {}:{}'.format(ext_port,
                                     int_port))
        site = "{}_{}".format(namespace, ext_port)
        site_path = os.path.join(sites_dir, site)
        with open(site_path, 'w') as fsite:
            context = {
                "ext": ext_port,
                "int": int_port,
                "namespace": namespace,
                "private_address": get_host_ip()
                }
            fsite.write(render_template(SITE_TEMPLATE,
                                        context))

        if RELOAD_CHECK in subprocess.check_output(['a2ensite', site]):
            http_restart = True

    if http_restart:
        restart('apache2')

    return True
Beispiel #20
0
     'pywebkitgtk.zip', SITE_PACKAGES),
    # TODO: Add chardet once we really use it and put it at the correct location.
    #('https://pypi.python.org/packages/source/c/chardet/chardet-2.1.1.tar.gz',
    # 'chardet-2.1.1.tar.gz', SITE_PACKAGES),
]

FILES = [('https://dl.dropboxusercontent.com/u/4780737/gtkspell.pyd',
          os.path.join(DRIVE_C_REAL, 'Python27', 'Lib', 'site-packages',
                       'gtkspell.pyd'))]

print HELP

for url, filename in INSTALLERS:
    path = os.path.join(INSTALLERS_DIR, filename)
    fetch(url, path)
    install(path, use_wine=IS_LINUX)

for url, filename, dest in TARBALLS:
    path = os.path.join(INSTALLERS_DIR, filename)
    fetch(url, path)
    cmd = ['wine'] if IS_LINUX else []
    assert path.endswith('.zip'), path
    cmd.extend([SEVEN_ZIP, 'x', '-o' + dest, path])
    run(cmd)

for url, dest in FILES:
    fetch(url, dest)

if IS_LINUX:
    time.sleep(10)  # Without this tar complains about changing files.
    dest_tarball = os.path.abspath(args.dest_tarball)
Beispiel #21
0
def install_node():
    install("ganglia-monitor")