資源簡介
Linux 12.04 版本備份
代碼片段和文件信息
#!/usr/bin/python
#?-*-?coding:?utf-8?-*-
#
#????作者:?ptptptptptpt?
#
#????This?program?is?free?software;?you?can?redistribute?it?and/or?modify
#????it?under?the?terms?of?the?GNU?General?Public?License?as?published?by
#????the?Free?Software?Foundation;?either?version?2?of?the?License?or
#????(at?your?option)?any?later?version.
#
#????This?program?is?distributed?in?the?hope?that?it?will?be?useful
#????but?WITHOUT?ANY?WARRANTY;?without?even?the?implied?warranty?of
#????MERCHANTABILITY?or?FITNESS?FOR?A?PARTICULAR?PURPOSE.??See?the
#????GNU?General?Public?License?for?more?details.
#
#????You?should?have?received?a?copy?of?the?GNU?General?Public?License
#????along?with?this?program;?if?not?write?to?the?Free?Software
#????Foundation?Inc.?51?Franklin?St?Fifth?Floor?Boston?MA??02110-1301??USA
#
import?os
import?sys
import?commands
import?time
import?signal
def?check_package_install(?pkg_name?):
????a?=?commands.getoutput(?‘dpkg?-l‘?)
????a?=?a.split(?‘\n‘?)
????for?each?in?a:
????????if?each[0:2]?==?‘ii‘?and?each.split()[1]?==?pkg_name:
????????????return?True
????????????
????return?False
def?check_target_partitions(?MountPointsConf?swap_part?cn_or_en?):
????#?是否指定了?/?分區
????if?not?(?‘/‘?in?MountPointsConf.keys()?):
????????if?cn_or_en?==?‘cn‘:
????????????return?[?1??‘錯誤:未指定?/?分區。\n‘?]
????????else:
????????????return?[?1?‘Error:?root?partition?is?unspecified.\n‘?]
????????
????#?檢查各掛載點的分區是否沖突
????for?each_mp?in?MountPointsConf:
????????for?each_mp2?in?MountPointsConf:
????????????if?MountPointsConf[each_mp][‘part‘]?==?MountPointsConf[each_mp2][‘part‘]?and?each_mp2?!=?each_mp?:
????????????????if?cn_or_en?==?‘cn‘:
????????????????????return?(2?‘錯誤:?%s?被同時指定到?“%s“?and?“%s“.\n‘?%(?MountPointsConf[each_mp][‘part‘]?each_mp?each_mp2)?)
????????????????else:
????????????????????return?(2?‘Error:?%s?is?assigned?repeatedly?to?“%s“?and?“%s“.\n‘?%(?MountPointsConf[each_mp][‘part‘]?each_mp?each_mp2)?)
????for?each_mp?in?MountPointsConf:
????????if?swap_part?==?MountPointsConf[each_mp][‘part‘]:
????????????if?cn_or_en?==?‘cn‘:
????????????????return?[?3??‘錯誤:%s?被同時指定為?“%s“?和?交換分區。\n‘%(?MountPointsConf[each_mp][‘part‘]?each_mp?)?]
????????????else:
????????????????return?[?3?‘Error:?%s?is?assigned?repeatedly?to?“%s“?and?swap.\n‘%(?MountPointsConf[each_mp][‘part‘]?each_mp?)?]
????#?檢查用于各分區的文件系統
????SupportFilesystems?=?(?‘current‘?‘ext2‘?‘ext3‘?‘ext4‘?‘reiserfs‘?‘jfs‘?‘xfs‘?)
????for?each_mp?in?MountPointsConf:
????????if?not?MountPointsConf[each_mp][‘fs‘]:
????????????if?cn_or_en?==?‘cn‘:
????????????????return?[?4??‘錯誤:未指定用于?“‘?+?each_mp?+?‘“?的文件系統。\n‘?]
????????????else:
????????????????return?[?4?‘Error:?filesystem?for?“‘?+?each_mp?+?‘“?is?unspecified.\n‘?]
????????elif?not?(?MountPointsConf[each_mp][‘fs‘]?in?SupportFilesystems?):
????????????if?cn_or_en?==?‘cn‘:
????????????????return?[?5??‘錯誤:不支持?“‘?+?MountPointsConf[each_mp][‘fs‘]?+?‘“?文件系統。‘?+
????????????????????????????‘\n可選文件系統:‘?+?‘?‘.joi
- 上一篇:cadence 17.0 網盤鏈接
- 下一篇:VRP問題蟻群算法
評論
共有 條評論