本文整理汇总了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;未经允许,请勿转载。 |
请发表评论