예제 #1
0
def index():
    """ The main Flask entry-point (/) for the Stallion server. """
    data = {'breadpath': [Crumb('Main')]}

    data.update(get_shared_data())
    data['menu_home'] = 'active'

    sys_info = {
        'Python Platform': sys.platform,
        'Python Version': sys.version,
        'Python Prefix': sys.prefix,
        'Machine Type': platform.machine(),
        'Platform': platform.platform(),
        'Processor': platform.processor()
    }

    try:
        sys_info['Python Implementation'] = platform.python_implementation()
    except:
        pass

    sys_info['System'] = platform.system()
    sys_info['System Arch'] = platform.architecture()

    data['system_information'] = sys_info

    return render_template('system_information.html', **data)
예제 #2
0
def index():
    """ The main Flask entry-point (/) for the Stallion server. """
    data = {'breadpath': [Crumb('Main')]}

    data.update(get_shared_data())
    data['menu_home'] = 'active'

    sys_info = {'Python Platform': sys.platform,
                'Python Version': sys.version,
                'Python Prefix': sys.prefix,
                'Machine Type': platform.machine(),
                'Platform': platform.platform(),
                'Processor': platform.processor()}

    try:
        sys_info['Python Implementation'] = platform.python_implementation()
    except:
        pass

    sys_info['System'] = platform.system()
    sys_info['System Arch'] = platform.architecture()

    data['system_information'] = sys_info

    return render_template('system_information.html', **data)
예제 #3
0
def cmd_list(args):
    '''This function implements the package list command.

    :param args: the docopt parsed arguments
    '''
    compact = args['--compact']
    filt = args['<filter>']
    distributions = get_shared_data()['distributions']

    if compact:
        print Fore.YELLOW + Style.BRIGHT + \
            'Project Name'.ljust(26) + 'Version'.ljust(14) + 'Summary'
        print '-' * 80

    for dist in distributions:
        if filt:
            if filt.lower() not in dist.project_name.lower():
                continue

        pkg_dist = get_pkg_res().get_distribution(dist.key)
        pkg_metadata = pkg_dist.get_metadata(metadata.METADATA_NAME)
        parsed, key_known = metadata.parse_metadata(pkg_metadata)
        distinfo = metadata.metadata_to_dict(parsed, key_known)

        if compact:
            cmd_list_compact(dist, distinfo)
        else:
            cmd_list_detail(dist, distinfo)
예제 #4
0
def cmd_list(args):
    '''This function implements the package list command.

    :param args: the docopt parsed arguments
    '''
    compact = args['--compact']
    filt = args['<filter>']
    distributions = get_shared_data()['distributions']

    if compact:
        print Fore.YELLOW + Style.BRIGHT + \
            'Project Name'.ljust(26) + 'Version'.ljust(14) + 'Summary'
        print '-' * 80
    
    for dist in distributions:
        if filt:
            if filt.lower() not in dist.project_name.lower():
                continue

        pkg_dist = get_pkg_res().get_distribution(dist.key)
        pkg_metadata = pkg_dist.get_metadata(metadata.METADATA_NAME)
        parsed, key_known = metadata.parse_metadata(pkg_metadata)
        distinfo = metadata.metadata_to_dict(parsed, key_known)

        if compact:
            cmd_list_compact(dist, distinfo)
        else:
            cmd_list_detail(dist, distinfo)
예제 #5
0
def console_scripts():
    """ Entry point for the global console scripts """
    data = {}
    data.update(get_shared_data())
    data['menu_console_scripts'] = 'active'
    data['breadpath'] = [Crumb('Console Scripts')]

    entry_console = get_pkg_res().iter_entry_points('console_scripts')
    data['scripts'] = entry_console

    return render_template('console_scripts.html', **data)
예제 #6
0
def console_scripts():
    """ Entry point for the global console scripts """
    data = {}
    data.update(get_shared_data())
    data['menu_console_scripts'] = 'active'
    data['breadpath'] = [Crumb('Console Scripts')]

    entry_console = get_pkg_res().iter_entry_points('console_scripts')
    data['scripts'] = entry_console

    return render_template('console_scripts.html', **data)
예제 #7
0
def about():
    """ The About entry-point (/about) for the Stallion server. """

    data = {}
    data.update(get_shared_data())
    data['menu_about'] = 'active'

    data['breadpath'] = [Crumb('About')]
    data['version'] = stallion.__version__
    data['author'] = stallion.__author__
    data['author_url'] = stallion.__author_url__

    return render_template('about.html', **data)
예제 #8
0
def about():
    """ The About entry-point (/about) for the Stallion server. """

    data = {}
    data.update(get_shared_data())
    data['menu_about'] = 'active'

    data['breadpath'] = [Crumb('About')]
    data['version'] = stallion.__version__
    data['author'] = stallion.__author__
    data['author_url'] = stallion.__author_url__

    return render_template('about.html', **data)
예제 #9
0
def distribution(dist_name=None):
    """ The Distribution entry-point (/distribution/<dist_name>)
    for the Stallion server.

    :param dist_name: the package name
    """

    pkg_dist = get_pkg_res().get_distribution(dist_name)

    data = {}
    data.update(get_shared_data())

    data['dist'] = pkg_dist
    data['breadpath'] = [
        Crumb('Main', url_for('index')),
        Crumb('Package'),
        Crumb(pkg_dist.project_name)
    ]

    settings_overrides = {
        'raw_enabled': 0,  # no raw HTML code
        'file_insertion_enabled': 0,  # no file/URL access
        'halt_level': 2,  # at warnings or errors, raise an exception
        'report_level': 5,  # never report problems with the reST code
    }

    pkg_metadata = pkg_dist.get_metadata(metadata.METADATA_NAME)
    parsed, key_known = metadata.parse_metadata(pkg_metadata)
    distinfo = metadata.metadata_to_dict(parsed, key_known)

    parts = None
    try:
        parts = publish_parts(source=distinfo['description'],
                              writer_name='html',
                              settings_overrides=settings_overrides)
    except:
        pass

    data['distinfo'] = distinfo
    data['entry_map'] = pkg_dist.get_entry_map()

    if parts is not None:
        data['description_render'] = parts['body']

    return render_template('distribution.html', **data)
예제 #10
0
def distribution(dist_name=None):
    """ The Distribution entry-point (/distribution/<dist_name>)
    for the Stallion server.

    :param dist_name: the package name
    """

    pkg_dist = get_pkg_res().get_distribution(dist_name)

    data = {}
    data.update(get_shared_data())

    data['dist'] = pkg_dist
    data['breadpath'] = [Crumb('Main', url_for('index')),
                         Crumb('Package'), Crumb(pkg_dist.project_name)]

    settings_overrides = {
        'raw_enabled': 0,  # no raw HTML code
        'file_insertion_enabled': 0,  # no file/URL access
        'halt_level': 2,  # at warnings or errors, raise an exception
        'report_level': 5,  # never report problems with the reST code
    }

    pkg_metadata = pkg_dist.get_metadata(metadata.METADATA_NAME)
    parsed, key_known = metadata.parse_metadata(pkg_metadata)
    distinfo = metadata.metadata_to_dict(parsed, key_known)

    parts = None
    try:
        parts = publish_parts(source=distinfo['description'],
                              writer_name='html',
                              settings_overrides=settings_overrides)
    except:
        pass

    data['distinfo'] = distinfo
    data['entry_map'] = pkg_dist.get_entry_map()

    if parts is not None:
        data['description_render'] = parts['body']

    return render_template('distribution.html', **data)
예제 #11
0
파일: test_main.py 프로젝트: mindw/stallion
 def test_get_shared_data_instance_true(self):
     data = main.get_shared_data()
     self.assertTrue(isinstance(data, dict))
     self.assertEqual(sorted(data.keys()), ['distributions',
                                            'pypi_update_cache'])
예제 #12
0
 def test_get_shared_data_instance_true(self):
     data = main.get_shared_data()
     self.assertTrue(isinstance(data, dict))
     self.assertEqual(sorted(data.keys()),
                      ['distributions', 'pypi_update_cache'])