Python version 模块,version() 实例源码

我们从Python开源项目中,提取了以下44个代码示例,用于说明如何使用version.version()

项目:Fuxenpruefung    作者:andb0t    | 项目源码 | 文件源码
def read_alerts():
    print('Retrieving info from', URL_MESSAGES, '...')
    messages = get_response_json(URL_MESSAGES)
    if messages is None:
        return None
    alerts = []
    for message in messages:
        messageFits = ((message['version'] == 'all') or (float(message['version']) >= version.version))
        messageHigher = ((message['version'] == 'all') or (float(message['version']) > version.version))
        categoryCheck = (message['category'] == 'alert') and messageFits
        versionCheck = (message['category'] == 'release') and messageHigher
        if not categoryCheck and not versionCheck:
            continue
        alerts.append(message)
    print_table(alerts)
    return alerts
项目:pyhttps    作者:talhasch    | 项目源码 | 文件源码
def main():
    logging.info('pyhttps {}'.format(version))
    create_ssl_cert()
    atexit.register(exit_handler)

    if PY3:
        import http.server
        import socketserver
        import ssl

        logging.info('Server running... https://{}:{}'.format(server_host, server_port))
        httpd = socketserver.TCPServer((server_host, server_port), http.server.SimpleHTTPRequestHandler)
        httpd.socket = ssl.wrap_socket(httpd.socket, certfile=ssl_cert_path, server_side=True)
    else:
        import BaseHTTPServer
        import SimpleHTTPServer
        import ssl

        logging.info('Server running... https://{}:{}'.format(server_host, server_port))
        httpd = BaseHTTPServer.HTTPServer((server_host, server_port), SimpleHTTPServer.SimpleHTTPRequestHandler)
        httpd.socket = ssl.wrap_socket(httpd.socket, certfile=ssl_cert_path, server_side=True)

    httpd.serve_forever()
项目:python_iotile_cloud    作者:iotile    | 项目源码 | 文件源码
def get_release_component():
    """Split the argument passed on the command line into a component name and expected version
    """

    global comp_names

    if len(sys.argv) < 2:
        raise EnvironmentError("Usage: python release.py <component_name>-<version>")

    name = 'iotile_cloud_api'
    vers = sys.argv[-1]

    #Allow versions to be vX.Y.Z
    if vers[0] == 'v':
        vers = vers[1:]

    if name not in comp_names:
        raise EnvironmentError("Invalid unknown release component name", name=name, known_names=comp_names.keys())

    return name, vers
项目:python_iotile_cloud    作者:iotile    | 项目源码 | 文件源码
def main():
    if len(sys.argv) < 2:
        print("Usage: release.py [--check] <component_name>-<version>")
        sys.exit(1)

    dry_run = False
    if sys.argv[-2] == '--check':
        dry_run = True

    component, version = get_release_component()
    check_version(component, version)
    build_component(component)

    #release_notes = get_release_notes(component, version)

    if dry_run:
        print("Check Release\nName: {}\nVersion: {}".format(component, version))
        #print("Release Notes:\n" + release_notes)
    else:
        upload_component(component)
        #send_slack_message('*Released {} version {} to PYPI*\n\nRelease Notes for version {}:\n```\n{}```'.format(component, version, version, release_notes))
项目:coretools    作者:iotile    | 项目源码 | 文件源码
def get_release_component():
    """Split the argument passed on the command line into a component name and expected version
    """

    global comp_names

    if len(sys.argv) < 2:
        raise EnvironmentError("Usage: python release.py <component_name>-<version>")

    comp = sys.argv[-1]
    name, vers = comp.split("-")

    if name not in comp_names:
        raise EnvironmentError("Invalid unknown release component name", name=name, known_names=comp_names.keys())

    return name, vers
项目:coretools    作者:iotile    | 项目源码 | 文件源码
def main():
    if len(sys.argv) < 2:
        print("Usage: release.py [--check] <component_name>-<version>")
        sys.exit(1)

    dry_run = False
    if sys.argv[-2] == '--check':
        dry_run = True

    component, version = get_release_component()
    check_version(component, version)
    build_component(component)

    release_notes = get_release_notes(component, version)

    if dry_run:
        print("Check Release\nName: {}\nVersion: {}".format(component, version))
        print("Release Notes:\n" + release_notes)
    else:
        upload_component(component)
        send_slack_message('*Released {} version {} to PYPI*\n\nRelease Notes for version {}:\n```\n{}```'.format(component, version, version, release_notes))
项目:OpenRAM    作者:mguthaus    | 项目源码 | 文件源码
def baselevels(self, s, maxlevel=1, brackets="()"):
        """strip parts of a string above a given bracket level
        - return a modified (some parts might be removed) version of the string s
          where all parts inside brackets with level higher than maxlevel are
          removed
        - if brackets do not match (number of left and right brackets is wrong
          or at some points there were more right brackets than left brackets)
          just return the unmodified string"""
        level = 0
        highestlevel = 0
        res = ""
        for c in s:
            if c == brackets[0]:
                level += 1
                if level > highestlevel:
                    highestlevel = level
            if level <= maxlevel:
                res += c
            if c == brackets[1]:
                level -= 1
        if level == 0 and highestlevel > 0:
            return res
项目:ConfigSpace    作者:automl    | 项目源码 | 文件源码
def get_info(dynamic=True):
    ## Date information
    date_info = datetime.datetime.now()
    date = time.asctime(date_info.timetuple())

    revision, version, version_info, vcs_info = None, None, None, None

    import_failed = False
    dynamic_failed = False

    if dynamic:
        revision, vcs_info = get_revision()
        if revision is None:
            dynamic_failed = True

    if dynamic_failed or not dynamic:
        # This is where most final releases of NetworkX will be.
        # All info should come from version.py. If it does not exist, then
        # no vcs information will be provided.
        sys.path.insert(0, basedir)
        try:
            from version import date, date_info, version, version_info, vcs_info
        except ImportError:
            import_failed = True
            vcs_info = (None, (None, None))
        else:
            revision = vcs_info[1][0]
        del sys.path[0]

    if import_failed or (dynamic and not dynamic_failed):
        # We are here if:
        #   we failed to determine static versioning info, or
        #   we successfully obtained dynamic revision info
        version = ''.join([str(major), '.', str(minor)])
        if dev:
            version += '.dev_' + date_info.strftime("%Y%m%d%H%M%S")
        version_info = (name, major, minor, revision)

    return date, date_info, version, version_info, vcs_info

## Version information
项目:forget    作者:codl    | 项目源码 | 文件源码
def inject_version():
    return dict(
            version=version.version,
            repo_url=libforget.version.url_for_version(version.version),
        )
项目:forget    作者:codl    | 项目源码 | 文件源码
def test_version_looks_like_a_version():
    assert re.match(
        'v?[0-9]+.[0-9]+.[0-9]+(-[A-Za-z0-9\-.]+)?',
        version.version)
项目:forget    作者:codl    | 项目源码 | 文件源码
def test_libversion_url():
    import libforget.version
    assert libforget.version.url_for_version(version.version)
项目:freshonions-torscraper    作者:dirtyfilthy    | 项目源码 | 文件源码
def inject_revision():
    return dict(revision=version.revision())
项目:freshonions-torscraper    作者:dirtyfilthy    | 项目源码 | 文件源码
def src():
    version_string = version.version()
    source_name="torscraper-%s.tar.gz" % version_string
    source_link="/static/%s" % source_name
    return render_template('src.html', source_name=source_name, source_link=source_link)
项目:freshonions-torscraper    作者:dirtyfilthy    | 项目源码 | 文件源码
def whatweb_list(name):
    version = request.args.get("version")
    account = request.args.get("account")
    string  = request.args.get("string")
    domains = WebComponent.find_domains(name, version=version, account=account, string=string)
    return render_template('whatweb_list.html', domains=domains, name=name, version=version, account=account, string=string)
项目:freshonions-torscraper    作者:dirtyfilthy    | 项目源码 | 文件源码
def whatweb_list_json(name):
    version = request.args.get("version")
    account = request.args.get("account")
    string  = request.args.get("string")
    domains = WebComponent.find_domains(name, version=version, account=account, string=string)
    return jsonify(Domain.to_dict_list(domains))
项目:ecel    作者:ARL-UTEP-OC    | 项目源码 | 文件源码
def ParseOptions(self):
        '''Read command line options
        '''
        parser = OptionParser(version=version.description + " version " + version.version + " (" + version.url + ").")
        parser.add_option("-d", "--debug", action="store_true", dest="debug", help="debug mode (print extra debug output) [default: %default]")
        parser.add_option("-t", "--disttype", action="store", dest="disttype", help="type of distribution to build ('standard', 'nonag', 'stealth', or 'all'). [default: %default]")
        parser.add_option("-u", "--uploadonly", action="store_true", dest="uploadonly", help="only upload the release, don't do the build. [default: %default]")

        parser.set_defaults(debug=False, 
                            disttype="all",
                            uploadonly=False)

        (self.cmdoptions, args) = parser.parse_args()
项目:ecel    作者:ARL-UTEP-OC    | 项目源码 | 文件源码
def version_check(self):
        if raw_input("Current version is " + version.version + ". Is that correct? [Y/N] ") in ["y", "Y", "yes", "YES", "Yes"]:
            pass
        else:
            sys.exit()
项目:ecel    作者:ARL-UTEP-OC    | 项目源码 | 文件源码
def toggle_stealth(self, new_name, new_description, icon_flag):
        ''' change name, description, in version.py, 
        rename the icon files and the ini and val files
        '''
        f = open('version.py','r')
        try:
            contents=f.readlines()
        finally:
            f.close()

        f = open('version.py','w')
        try:
            for line in contents:
                line = re.sub('^( *name = ).*', '\\1' + '"' + new_name + '"', line)
                line = re.sub('^( *description = ).*', '\\1' + '"' + new_description + '"', line)
                #line = re.sub('^( *window_title = ).*', '\\1' + '"' + new_window_title + '"', line)
                f.write(line)
                #if re.search('^( +NagMe = )', line):
                    #print line
        finally:
            f.close()

        if icon_flag == 1:
            shutil.copy(version.name + '.ini', new_name + '.ini')
            shutil.copy(version.name + '.val', new_name + '.val')
            shutil.copy(version.name + 'icon.ico', new_name + 'icon.ico')
            shutil.copy(version.name + 'icon.svg', new_name + 'icon.svg')
            shutil.copy(version.name + 'icon_big.gif', new_name + 'icon_big.gif')
        else:
            os.remove(icon_flag + '.ini')
            os.remove(icon_flag + '.val')
            os.remove(icon_flag + 'icon.ico')
            os.remove(icon_flag + 'icon.svg')
            os.remove(icon_flag + 'icon_big.gif')
项目:ecel    作者:ARL-UTEP-OC    | 项目源码 | 文件源码
def update_nsis_script_version(self):
        f = open('pykeylogger_install_script.nsi','r')
        try:
            contents=f.readlines()
        finally:
            f.close()

        f = open('pykeylogger_install_script.nsi','w')
        try:
            for line in contents:
                line = re.sub('^( *!define PYKEYLOGGER_VERSION ).*', '\\1' + '"' + version.version + '"', line)
                f.write(line)
        finally:
            f.close()
项目:ecel    作者:ARL-UTEP-OC    | 项目源码 | 文件源码
def initialize_main_panel(self):
        #create the main panel window
        #root = Tk()
        #root.title("PyKeylogger Control Panel")
        # create a menu

        self.root.title("PyKeylogger Control Panel")
        self.root.config(height=200, width=200)

        self.root.protocol("WM_DELETE_WINDOW", self.close)

        # Display the version in main window
        g = Pmw.Group(self.root, tag_pyclass = None)
        g.pack(fill = 'both', expand = 1, padx = 6, pady = 6)
        textlabel = Label(g.interior(), 
                    text="PyKeylogger " + str(version.version),
                    font=("Helvetica", 18))
        textlabel.pack(padx = 2, pady = 2, expand='yes', fill='both')

        # Pretty logo display
        photo = PhotoImage(file=os.path.join(myutils.get_main_dir(), 
                                    version.name + "icon_big.gif"))
        imagelabel = Label(self.root, image=photo, height=160, width=200)
        imagelabel.photo = photo
        imagelabel.pack()

        # Create and pack the MessageBar.
        self.message_bar = Pmw.MessageBar(self.root,
                entry_width = 50,
                entry_relief='groove',
                labelpos = 'w',
                label_text = 'Status:')
        self.message_bar.pack(fill = 'x', padx = 10, pady = 10)
        self.message_bar.message('state',
            'Please explore the menus.')

        # Create main menu
        menu = MainMenu(self.root, self.panelsettings, self)
项目:ecel    作者:ARL-UTEP-OC    | 项目源码 | 文件源码
def __init__(self):
            self.configfile=version.name + ".ini"
            self.configval=version.name + ".val"
项目:python_iotile_cloud    作者:iotile    | 项目源码 | 文件源码
def check_version(component, expected_version):
    """Make sure the package version in setuptools matches what we expect it to be
    """

    _, relative_compath = comp_names[component]

    compath = os.path.realpath(os.path.abspath(relative_compath))
    sys.path.insert(0, compath)

    import version

    if version.version != expected_version:
        raise EnvironmentError("Version mismatch during release, expected={}, found={}".format(expected_version, version.version))
项目:python_iotile_cloud    作者:iotile    | 项目源码 | 文件源码
def get_release_notes(component, version):
    _, relative_compath = comp_names[component]
    notes_path = os.path.join(relative_compath, 'RELEASE.md')

    try:
        with open(notes_path, "r") as f:
            lines = f.readlines()
    except IOError:
        print("ERROR: Could not find release notes file RELEASE.md")
        sys.exit(1)

    release_lines = {y[2:].strip(): x for x, y in enumerate(lines) if y.startswith('##')}

    if version not in release_lines:
        print("ERROR: Could not find release notes for current release version")
        sys.exit(1)

    start_line = release_lines[version]
    past_releases = [x for x in release_lines.itervalues() if x > start_line]

    if len(past_releases) == 0:
        release_string = "".join(lines[start_line+1:])
    else:
        release_string = "".join(lines[start_line:min(past_releases)])

    if len(release_string) == 0:
        print("ERROR: Empty release notes for current release version")
        sys.exit(1)

    return release_string
项目:larissa    作者:bannsec    | 项目源码 | 文件源码
def _get_boost_version(boost_path):
    # Assuming the path exists here
    # Return (major, minor, patch)

    with open(os.path.join(boost_path,"boost","version.hpp"),"r") as f:
        data = f.read()

    version = int(re.findall("#define +BOOST_VERSION +([0-9]+)",data)[0])

    return version / 100000, version / 100 % 1000, version % 100
项目:larissa    作者:bannsec    | 项目源码 | 文件源码
def _is_boost_new_enough(boost_path):
    # Caveat, it has to be a high enough version...
    major, minor, patch = _get_boost_version(boost_path)

    if major > 1:
        return True

    if major == 1 and minor >= 55:
        return True

    return False
项目:larissa    作者:bannsec    | 项目源码 | 文件源码
def _install_boost():
    """Determine if we need to install liboost, and do so."""

    # If it's already installed, don't install it.
    if _get_boost_path() != None:

        # Caveat, it has to be a high enough version...
        major, minor, patch = _get_boost_version(_get_boost_path())

        if major > 1:
            return

        if major == 1 and minor >= 55:
            return

    print("Installing boost.")

    # Looks like we need to build it
    try:
        #out = subprocess.check_output("pip install -vvv larissa_boost",shell=True)
        # No idea why setup.py correctly installs larissa_boost in this case where pip does not.
        os.system("pip download larissa_boost")
        os.system("tar xf larissa_boost*")
        _, names, _ = next(os.walk("."))
        os.chdir([name for name in names if "larissa_boost" in name][0])
        out = subprocess.check_output("python setup.py install",shell=True)
    except Exception as e:
        raise Exception(e.output)

    print(out)
    print(os.system("ls -la $VIRTUAL_ENV/"))
    print(os.system("ls -la $VIRTUAL_ENV/include/"))
    print(os.system("ls -la $VIRTUAL_ENV/boost/"))
    print(os.system("ls -la $VIRTUAL_ENV/boost/include"))
项目:larissa    作者:bannsec    | 项目源码 | 文件源码
def _install_triton():
    # Locate the needed libraries
    capstone_include = re.match("(.*)/capstone$", find_file("capstone.h")).group(1)
    capstone_lib = os.path.join(find_file("libcapstone.so"),"libcapstone.so")
    cpath = [find_file("z3++.h")]
    cpath.append(find_file("z3.h"))
    cpath.append(find_file("z3_ast_containers.h"))

    # Using triton version included in larissa due to triton not being in pypi
    os.chdir(os.path.join(here,"lib","triton"))
    os.mkdir("build")
    os.chdir("build")

    cmake_options = [
            '-DCMAKE_INSTALL_PREFIX={0}'.format(sys.prefix),
            '-DCAPSTONE_INCLUDE_DIR={0}'.format(capstone_include),
            '-DCAPSTONE_LIBRARY={0}'.format(capstone_lib)
            ]

    # Custom boost install dir
    if _get_boost_path() != "/usr/include":
        cmake_options.append("-DBoost_INCLUDE_DIR={0}".format(os.path.join(_get_boost_path(),"include")))
        cmake_options.append("-DBoost_LIBRARY_DIR={0}".format(os.path.join(_get_boost_path(),"lib")))

        cpath = ["/usr/include"] + cpath
        cpath.append(os.path.join(_get_boost_path(),"include"))

    try:
        print("cmake {0} ..".format(' '.join(cmake_options)))
        subprocess.check_output("cmake {0} ..".format(' '.join(cmake_options)),shell=True)
    except Exception as e:
        raise Exception(e.output)

    try:
        print("CPATH={1} make -j{0} install".format(multiprocessing.cpu_count(), ':'.join(cpath)))
        subprocess.check_output("CPATH={1} make -j{0} install".format(multiprocessing.cpu_count(), ':'.join(cpath)),shell=True)
    except Exception as e:
        raise Exception(e.output)

    os.chdir(here)
项目:pyprophet    作者:PyProphet    | 项目源码 | 文件源码
def print_help():
    print
    script = os.path.basename(sys.argv[0])
    print "usage:"
    print "       %s [options] input_file [input_file ...]" % script
    print "   or "
    print "       %s --help" % script
    print "   or "
    print "       %s --version" % script
    dump_config_info(CONFIG.config, CONFIG.info)
项目:pyprophet    作者:PyProphet    | 项目源码 | 文件源码
def print_version():
    import version
    print "%d.%d.%d" % version.version
项目:pyprophet    作者:PyProphet    | 项目源码 | 文件源码
def parse_cmdline(args):

    options = dict()
    pathes = []

    if "--help" in args:
        print_help()
        sys.exit(0)

    if "--version" in args:
        print_version()
        sys.exit(0)

    for arg in args:
        if arg.startswith("--"):
            if "=" in arg:
                pre, __, post = arg.partition("=")
                options[pre[2:]] = post
            else:
                options[arg[2:]] = True
        else:
            pathes.append(arg)

    if not pathes:
        print_help()
        raise Exception("no input file given")

    CONFIG.update(options)
    dump_config(CONFIG.config)

    return pathes
项目:FBoT    作者:pipesocks    | 项目源码 | 文件源码
def main():
    parser = argparse.ArgumentParser(prog = 'FBoT', description = 'Foo or Bar over TLS.')
    parser.add_argument('-v', '--version', action = 'version', version='%(prog)s ' + version.version)
    parser.add_argument('config', help = 'the JSON config file to load', type = argparse.FileType('r'))
    with parser.parse_args().config as fp:
        config.load(fp)
    tcpserver.TCPServer().listen()
项目:shadowsocks-remix    作者:SuperSuperSuperSuper5    | 项目源码 | 文件源码
def check_python():
    info = sys.version_info
    if info[0] == 2 and not info[1] >= 6:
        print('Python 2.6+ required')
        sys.exit(1)
    elif info[0] == 3 and not info[1] >= 3:
        print('Python 3.3+ required')
        sys.exit(1)
    elif info[0] not in [2, 3]:
        print('Python version not supported')
        sys.exit(1)
项目:shadowsocks-remix    作者:SuperSuperSuperSuper5    | 项目源码 | 文件源码
def print_shadowsocks():
    version_str = ''
    try:
        import version
        version_str = version.version()
    except Exception:
        pass
    print('ShadowsocksR %s' % version_str)
项目:shadowsocks-remix    作者:SuperSuperSuperSuper5    | 项目源码 | 文件源码
def log_shadowsocks_version():
    version_str = ''
    try:
        import version
        version_str = version.version()
    except Exception:
        pass
    logging.info('ShadowsocksR %s' % version_str)
项目:shadowsocks-remix    作者:SuperSuperSuperSuper5    | 项目源码 | 文件源码
def print_local_help():
    print('''usage: sslocal [OPTION]...
A fast tunnel proxy that helps you bypass firewalls.

You can supply configurations via either config file or command line arguments.

Proxy options:
  -c CONFIG              path to config file
  -s SERVER_ADDR         server address
  -p SERVER_PORT         server port, default: 8388
  -b LOCAL_ADDR          local binding address, default: 127.0.0.1
  -l LOCAL_PORT          local port, default: 1080
  -k PASSWORD            password
  -m METHOD              encryption method, default: aes-256-cfb
  -o OBFS                obfsplugin, default: http_simple
  -t TIMEOUT             timeout in seconds, default: 300
  --fast-open            use TCP_FASTOPEN, requires Linux 3.7+

General options:
  -h, --help             show this help message and exit
  -d start/stop/restart  daemon mode
  --pid-file PID_FILE    pid file for daemon mode
  --log-file LOG_FILE    log file for daemon mode
  --user USER            username to run as
  -v, -vv                verbose mode
  -q, -qq                quiet mode, only show warnings/errors
  --version              show version information

Online help: <https://github.com/shadowsocks/shadowsocks>
''')
项目:shadowsocks-remix    作者:SuperSuperSuperSuper5    | 项目源码 | 文件源码
def print_server_help():
    print('''usage: ssserver [OPTION]...
A fast tunnel proxy that helps you bypass firewalls.

You can supply configurations via either config file or command line arguments.

Proxy options:
  -c CONFIG              path to config file
  -s SERVER_ADDR         server address, default: 0.0.0.0
  -p SERVER_PORT         server port, default: 8388
  -k PASSWORD            password
  -m METHOD              encryption method, default: aes-256-cfb
  -o OBFS                obfsplugin, default: http_simple
  -t TIMEOUT             timeout in seconds, default: 300
  --fast-open            use TCP_FASTOPEN, requires Linux 3.7+
  --workers WORKERS      number of workers, available on Unix/Linux
  --forbidden-ip IPLIST  comma seperated IP list forbidden to connect
  --manager-address ADDR optional server manager UDP address, see wiki

General options:
  -h, --help             show this help message and exit
  -d start/stop/restart  daemon mode
  --pid-file PID_FILE    pid file for daemon mode
  --log-file LOG_FILE    log file for daemon mode
  --user USER            username to run as
  -v, -vv                verbose mode
  -q, -qq                quiet mode, only show warnings/errors
  --version              show version information

Online help: <https://github.com/shadowsocks/shadowsocks>
''')
项目:coretools    作者:iotile    | 项目源码 | 文件源码
def check_version(component, expected_version):
    """Make sure the package version in setuptools matches what we expect it to be
    """

    _, relative_compath = comp_names[component]

    compath = os.path.realpath(os.path.abspath(relative_compath))
    sys.path.insert(0, compath)

    import version

    if version.version != expected_version:
        raise EnvironmentError("Version mismatch during release, expected={}, found={}".format(expected_version, version.version))
项目:coretools    作者:iotile    | 项目源码 | 文件源码
def get_release_notes(component, version):
    _, relative_compath = comp_names[component]
    notes_path = os.path.join(relative_compath, 'RELEASE.md')

    try:
        with open(notes_path, "r") as f:
            lines = f.readlines()
    except IOError:
        print("ERROR: Could not find release notes file RELEASE.md")
        sys.exit(1)

    release_lines = {y[2:].strip(): x for x, y in enumerate(lines) if y.startswith('##')}

    if version not in release_lines:
        print("ERROR: Could not find release notes for current release version")
        sys.exit(1)

    start_line = release_lines[version]
    past_releases = [x for x in release_lines.itervalues() if x > start_line]

    if len(past_releases) == 0:
        release_string = "".join(lines[start_line+1:])
    else:
        release_string = "".join(lines[start_line:min(past_releases)])

    if len(release_string) == 0:
        print("ERROR: Empty release notes for current release version")
        sys.exit(1)

    return release_string
项目:cello    作者:yeasy    | 项目源码 | 文件源码
def health():
    request_debug(r, logger)
    result = {
        'health': 'OK',
        'version': version
    }

    return jsonify(result), CODE_OK
项目:cello    作者:yeasy    | 项目源码 | 文件源码
def about():
    logger.info("path={}, method={}".format(r.path, r.method))
    return render_template("about.html", author=author, version=version,
                           homepage=homepage)
项目:OpenRAM    作者:mguthaus    | 项目源码 | 文件源码
def write(self, file, writer, registry):
        if time.timezone < 0:
            # divmod on positive numbers, otherwise the minutes have a different sign from the hours
            timezone = "-%02i'%02i'" % divmod(-time.timezone/60, 60)
        elif time.timezone > 0:
            timezone = "+%02i'%02i'" % divmod(time.timezone/60, 60)
        else:
            timezone = "Z00'00'"

        def pdfstring(s):
            r = ""
            for c in s:
                if 32 <= ord(c) <= 127 and c not in "()[]<>\\":
                    r += c
                else:
                    r += "\\%03o" % ord(c)
            return r

        file.write("<<\n")
        if writer.title:
            file.write("/Title (%s)\n" % pdfstring(writer.title))
        if writer.author:
            file.write("/Author (%s)\n" % pdfstring(writer.author))
        if writer.subject:
            file.write("/Subject (%s)\n" % pdfstring(writer.subject))
        if writer.keywords:
            file.write("/Keywords (%s)\n" % pdfstring(writer.keywords))
        file.write("/Creator (PyX %s)\n" % version.version)
        file.write("/CreationDate (D:%s%s)\n" % (time.strftime("%Y%m%d%H%M"), timezone))
        file.write(">>\n")
项目:ecel    作者:ARL-UTEP-OC    | 项目源码 | 文件源码
def build_executable(self):

        #delete old build dir.
        print r'rd /S /Q build'
        os.system(r'rd /S /Q build')

        #delete old dist dir
        print r'rd /S /Q dist'
        os.system(r'rd /S /Q dist')

        # create the exe 
        print r'c:\Python25\python setup.py py2exe'
        os.system(r'c:\Python25\python setup.py py2exe')

        print r'rename "dist" "pykeylogger-' + version.version + '""'
        os.system(r'rename "dist" "pykeylogger-' + version.version + '""')

        self.build_nsis_installer()

        print r'move ".\pykeylogger-' + version.version + r'_win32_installer.exe" ".\pykeylogger-' + version.version + self.filename_addendum + r'_win32_installer.exe"'
        os.system(r'move ".\pykeylogger-' + version.version + r'_win32_installer.exe" ".\pykeylogger-' + version.version + self.filename_addendum + r'_win32_installer.exe"')

        print "zipping executables"
        self.ZipFiles(r"pykeylogger-" + version.version, "pykeylogger-" + version.version + self.filename_addendum + "_win32.zip")

        print r'rd /S /Q pykeylogger-' + version.version
        os.system(r'rd /S /Q pykeylogger-' + version.version)
        print r'rd /S /Q build'
        os.system(r'rd /S /Q build')

        # create md5sum
        print r'""C:\Progra~1\UnixUtils\md5sum.exe" "pykeylogger-' + version.version + self.filename_addendum + r'_win32.zip" > "..\pykeylogger-' + version.version + self.filename_addendum + '_win32_md5sum.txt""'
        os.system(r'""C:\Progra~1\UnixUtils\md5sum.exe" "pykeylogger-' + version.version + self.filename_addendum + r'_win32.zip" > "..\pykeylogger-' + version.version + self.filename_addendum + '_win32_md5sum.txt""')
        print r'""C:\Progra~1\UnixUtils\md5sum.exe" ".\pykeylogger-' + version.version + self.filename_addendum + r'_win32_installer.exe" > "..\pykeylogger-' + version.version + self.filename_addendum + r'_win32_installer_md5sum.txt""'
        os.system(r'""C:\Progra~1\UnixUtils\md5sum.exe" ".\pykeylogger-' + version.version + self.filename_addendum + r'_win32_installer.exe" > "..\pykeylogger-' + version.version + self.filename_addendum + r'_win32_installer_md5sum.txt""')

        # move release files out of the source dir
        print r'move ".\pykeylogger-' + version.version + self.filename_addendum + r'_win32.zip" "..\pykeylogger-' + version.version + self.filename_addendum + '_win32.zip"'
        os.system(r'move ".\pykeylogger-' + version.version + self.filename_addendum + r'_win32.zip" "..\pykeylogger-' + version.version + self.filename_addendum + '_win32.zip"')

        print r'move ".\pykeylogger-' + version.version + self.filename_addendum + r'_win32_installer.exe" "..\pykeylogger-' + version.version + self.filename_addendum + '_win32_installer.exe"'
        os.system(r'move ".\pykeylogger-' + version.version + self.filename_addendum +  r'_win32_installer.exe" "..\pykeylogger-' + version.version + self.filename_addendum + '_win32_installer.exe"')

        #os.system(r'pause')
项目:toil-lib    作者:BD2KGenomics    | 项目源码 | 文件源码
def check_provided(distribution, min_version, max_version=None, optional=False):
    # taken from https://github.com/BD2KGenomics/toil-scripts/blob/master/setup.py
    min_version = parse_version(min_version)
    if isinstance(min_version, tuple):
        raise RuntimeError("Setuptools version 8.0 or newer required. Update by running "
                           "'pip install setuptools --upgrade'")
    if max_version is not None:
        max_version = parse_version(max_version)

    messages = []

    toil_missing = 'Cannot find a valid installation of Toil.'
    dist_missing = 'Cannot find an installed copy of the %s distribution, typically provided by Toil.' % distribution
    version_too_low = 'The installed copy of %s is out of date.' % distribution
    version_too_high = 'The installed copy of %s is too new.' % distribution
    required_version = 'Setup requires version %s or higher' % min_version
    required_version += '.' if max_version is None else ', up to but not including %s.' % max_version
    install_toil = 'Installing Toil should fix this problem.'
    upgrade_toil = 'Upgrading Toil should fix this problem.'
    reinstall_dist = 'Uninstalling %s and reinstalling Toil should fix this problem.' % distribution
    reinstall_toil = 'Uninstalling Toil and reinstalling it should fix this problem.'
    footer = ("Setup doesn't install Toil automatically to give you a chance to choose any of the optional extras "
              "that Toil provides. More on installing Toil at http://toil.readthedocs.io/en/latest/installation.html.")
    try:
        # This check will fail if the distribution or any of its dependencies are missing.
        installed_version = parse_version(require(distribution)[0].version)
    except DistributionNotFound:
        installed_version = None
        if not optional:
            messages.extend([toil_missing if distribution == 'toil' else dist_missing, install_toil])
    else:
        if installed_version < min_version:
            messages.extend([version_too_low, required_version,
                             upgrade_toil if distribution == 'toil' else reinstall_dist])
        elif max_version is not None and max_version < installed_version:
            messages.extend([version_too_high, required_version,
                             reinstall_toil if distribution == 'toil' else reinstall_dist])
    if messages:
        messages.append(footer)
        raise RuntimeError(' '.join(messages))
    else:
        return str(installed_version)
项目:OpenRAM    作者:mguthaus    | 项目源码 | 文件源码
def __init__(self, document, file):
        if len(document.pages) != 1:
            raise ValueError("EPS file can be constructed out of a single page document only")
        page = document.pages[0]
        canvas = page.canvas

        try:
            file.write("")
        except:
            filename = file
            if not filename.endswith(".eps"):
                filename += ".eps"
            try:
                file = open(filename, "w")
            except IOError:
                raise IOError("cannot open output file")
        else:
            filename = "stream"

        pagefile = cStringIO.StringIO()
        registry = PSregistry()
        acontext = context()
        pagebbox = bbox.empty()

        page.processPS(pagefile, self, acontext, registry, pagebbox)

        file.write("%!PS-Adobe-3.0 EPSF-3.0\n")
        if pagebbox:
            file.write("%%%%BoundingBox: %d %d %d %d\n" % pagebbox.lowrestuple_pt())
            file.write("%%%%HiResBoundingBox: %g %g %g %g\n" % pagebbox.highrestuple_pt())
        file.write("%%%%Creator: PyX %s\n" % version.version)
        file.write("%%%%Title: %s\n" % filename)
        file.write("%%%%CreationDate: %s\n" %
                   time.asctime(time.localtime(time.time())))
        file.write("%%EndComments\n")

        file.write("%%BeginProlog\n")
        registry.output(file, self)
        file.write("%%EndProlog\n")

        file.write(pagefile.getvalue())
        pagefile.close()

        file.write("showpage\n")
        file.write("%%Trailer\n")
        file.write("%%EOF\n")