• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python menuinst.install函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中menuinst.install函数的典型用法代码示例。如果您正苦于以下问题:Python install函数的具体用法?Python install怎么用?Python install使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了install函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: mk_menus

def mk_menus(remove=False, prefix=None):
    try:
        import menuinst
    except (ImportError, OSError):
        return
    if prefix is None:
        prefix = sys.prefix
    menu_dir = join(prefix, 'Menu')
    if not os.path.isdir(menu_dir):
        return
    pkg_names = [s.strip() for s in sys.argv[2:]]
    for fn in os.listdir(menu_dir):
        if not fn.endswith('.json'):
            continue
        if pkg_names and fn[:-5] not in pkg_names:
            continue
        shortcut = join(menu_dir, fn)
        try:
            menuinst.install(shortcut, remove, prefix=prefix)
        except Exception as e:
            out("Failed to process %s...\n" % shortcut)
            err("Error: %s\n" % str(e))
            err("Traceback:\n%s\n" % traceback.format_exc(20))
        else:
            out("Processed %s successfully.\n" % shortcut)
开发者ID:DamirAinullin,项目名称:PTVS,代码行数:25,代码来源:_nsis.py


示例2: mk_menus

def mk_menus(prefix, files, remove=False):
    """
    Create cross-platform menu items (e.g. Windows Start Menu)

    Passes all menu config files %PREFIX%/Menu/*.json to ``menuinst.install``.
    ``remove=True`` will remove the menu items.
    """
    menu_files = [f for f in files
                  if (f.lower().startswith('menu/') and
                      f.lower().endswith('.json'))]
    if not menu_files:
        return
    elif basename(abspath(prefix)).startswith('_'):
        logging.warn("Environment name starts with underscore '_'.  "
                     "Skipping menu installation.")
        return

    try:
        import menuinst
    except:
        logging.warn("Menuinst could not be imported:")
        logging.warn(traceback.format_exc())
        return

    for f in menu_files:
        try:
            menuinst.install(join(prefix, f), remove, prefix)
        except:
            stdoutlog.error("menuinst Exception:")
            stdoutlog.error(traceback.format_exc())
开发者ID:artemh,项目名称:conda,代码行数:30,代码来源:install.py


示例3: mk_menus

def mk_menus(prefix, files, remove=False):
    """
    Create cross-platform menu items (e.g. Windows Start Menu)

    Passes all menu config files %PREFIX%/Menu/*.json to ``menuinst.install``.
    ``remove=True`` will remove the menu items.
    """
    # exclude all envs starting with '_'
    if basename(abspath(prefix)).startswith('_'):
        return

    menu_files = [f for f in files
                  if f.lower().startswith('menu/')
                  and f.lower().endswith('.json')]
    if not menu_files:
        return
    try:
        import menuinst
    except ImportError:
        return
    for f in menu_files:
        try:
            menuinst.install(join(prefix, f), remove, prefix)
        except:
            stdoutlog.error("menuinst Exception:")
            stdoutlog.error(traceback.format_exc())
开发者ID:gqmelo,项目名称:conda,代码行数:26,代码来源:install.py


示例4: main

def main():
    from optparse import OptionParser

    p = OptionParser(
        usage="usage: %prog [options] MENU_FILE",
        description="install a menu item")

    p.add_option('-p', '--prefix',
                 action="store",
                 default=sys.prefix)

    p.add_option('--remove',
                 action="store_true")

    p.add_option('--version',
                 action="store_true")

    opts, args = p.parse_args()

    if opts.version:
        sys.stdout.write("menuinst: %s\n" % menuinst.__version__)
        return

    for arg in args:
        menuinst.install(join(opts.prefix, arg), opts.remove, opts.prefix)
开发者ID:ContinuumIO,项目名称:menuinst,代码行数:25,代码来源:main.py


示例5: test_create_and_remove_shortcut

 def test_create_and_remove_shortcut(self):
     nonadmin=os.path.join(sys.prefix, ".nonadmin")
     shortcut = os.path.join(menu_dir, "menu-windows.json")
     has_nonadmin = os.path.exists(nonadmin)
     for mode in ["user", "system"]:
         if mode=="user":
             open(nonadmin, 'a').close()
         menuinst.install(shortcut, remove=False)
         menuinst.install(shortcut, remove=True)
         if os.path.exists(nonadmin):
             os.remove(nonadmin)
     if has_nonadmin:
         open(nonadmin, 'a').close()
开发者ID:ContinuumIO,项目名称:menuinst,代码行数:13,代码来源:test_menu_creation.py


示例6: mk_menus

def mk_menus(remove=False):
    try:
        import menuinst
    except ImportError:
        return
    menu_dir = join(sys.prefix, 'Menu')
    if os.path.exists(menu_dir):
        for fn in os.listdir(menu_dir):
            if fn.endswith('.json'):
                shortcut = join(menu_dir, fn)
                try:
                    menuinst.install(shortcut, remove)
                except Exception as e:
                    out("Failed to process %s...\n" % shortcut)
                    err("Error: %s\n" % str(e))
                    err("Traceback:\n%s\n" % traceback.format_exc(20))
                else:
                    out("Processed %s successfully.\n" % shortcut)
开发者ID:aseemdrockstar,项目名称:constructor,代码行数:18,代码来源:_nsis.py


示例7: make_menu

def make_menu(prefix, file_path, remove=False):
    """
    Create cross-platform menu items (e.g. Windows Start Menu)

    Passes all menu config files %PREFIX%/Menu/*.json to ``menuinst.install``.
    ``remove=True`` will remove the menu items.
    """
    if not on_win:
        return
    elif basename(prefix).startswith('_'):
        log.warn("Environment name starts with underscore '_'. Skipping menu installation.")
        return

    try:
        import menuinst
        menuinst.install(join(prefix, win_path_ok(file_path)), remove, prefix)
    except:
        stdoutlog.error("menuinst Exception", exc_info=True)
开发者ID:groutr,项目名称:conda,代码行数:18,代码来源:create.py


示例8: mk_menus

def mk_menus(prefix, files, remove=False):
    if abspath(prefix) != abspath(sys.prefix):
        # we currently only want to create menu items for packages
        # in default environment
        return
    menu_files = [f for f in files
                  if f.startswith('Menu/') and f.endswith('.json')]
    if not menu_files:
        return
    try:
        import menuinst
    except ImportError:
        return
    for f in menu_files:
        try:
            menuinst.install(join(prefix, f), remove, prefix)
        except:
            stdoutlog.error("menuinst Exception:")
            stdoutlog.error(traceback.format_exc())
开发者ID:gitter-badger,项目名称:conda,代码行数:19,代码来源:install.py


示例9: mk_menus

def mk_menus(prefix, files, remove=False):
    """
    Create cross-platform menu items (e.g. Windows Start Menu)

    Passes all menu config files %PREFIX%/Menu/*.json to ``menuinst.install``.
    ``remove=True`` will remove the menu items.
    """
    menu_files = [f for f in files
                  if f.lower().startswith('menu/')
                  and f.lower().endswith('.json')]
    if not menu_files:
        return
    elif basename(abspath(prefix)).startswith('_'):
        logging.warn("Environment name starts with underscore '_'.  "
                     "Skipping menu installation.")
        return

    try:
        import menuinst
    except:
        logging.warn("Menuinst could not be imported:")
        logging.warn(traceback.format_exc())
        return

    env_name = (None if abspath(prefix) == abspath(sys.prefix) else
                basename(prefix))
    # only windows is provided right now.  Add "source activate" if on Unix platforms
    env_setup_cmd = "activate"
    if env_name:
        env_setup_cmd = env_setup_cmd + " %s" % env_name

    for f in menu_files:
        try:
            if menuinst.__version__.startswith('1.0'):
                menuinst.install(join(prefix, f), remove, prefix)
            else:
                menuinst.install(join(prefix, f), remove,
                                 root_prefix=sys.prefix,
                                 target_prefix=prefix, env_name=env_name,
                                 env_setup_cmd=env_setup_cmd)
        except:
            stdoutlog.error("menuinst Exception:")
            stdoutlog.error(traceback.format_exc())
开发者ID:Studiogit,项目名称:conda,代码行数:43,代码来源:install.py



注:本文中的menuinst.install函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python menumanager.MenuManager类代码示例发布时间:2022-05-27
下一篇:
Python menu.Menu类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap