本文整理汇总了Python中General.sudo_mode方法的典型用法代码示例。如果您正苦于以下问题:Python General.sudo_mode方法的具体用法?Python General.sudo_mode怎么用?Python General.sudo_mode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类General
的用法示例。
在下文中一共展示了General.sudo_mode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: start_with_computer
# 需要导入模块: import General [as 别名]
# 或者: from General import sudo_mode [as 别名]
def start_with_computer(enabled):
"""If enabled, create shortcut to start application with computer.
If disabled, then delete the shortcut."""
if not enabled:
if os.path.lexists(autostart_path):
FileUtilities.delete(autostart_path)
return
if os.path.lexists(autostart_path):
return
import shutil
General.makedirs(os.path.dirname(autostart_path))
shutil.copy(launcher_path, autostart_path)
os.chmod(autostart_path, 0755)
if General.sudo_mode():
General.chownself(autostart_path)
示例2: start_with_computer
# 需要导入模块: import General [as 别名]
# 或者: from General import sudo_mode [as 别名]
def start_with_computer(enabled):
"""If enabled, create shortcut to start application with computer.
If disabled, then delete the shortcut."""
if not enabled:
# User requests to not automatically start BleachBit
if os.path.lexists(autostart_path):
# Delete the shortcut
FileUtilities.delete(autostart_path)
return
# User requests to automatically start BleachBit
if os.path.lexists(autostart_path):
# Already automatic, so exit
return
if not os.path.exists(Common.launcher_path):
print 'ERROR: does not exist: ', Common.launcher_path
return
import shutil
General.makedirs(os.path.dirname(autostart_path))
shutil.copy(Common.launcher_path, autostart_path)
os.chmod(autostart_path, 0755)
if General.sudo_mode():
General.chownself(autostart_path)