1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
|
#! @PYTHON@ @PYOPTIONS@
# -*- python -*-
# -*- coding: UTF-8 -*-
#
# disk-manager : GTK Disk Manager
# Copyright (C) 2007 Mertens Florent <flomertens@gmail.com>
#
# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
import os
import sys
import logging
import gettext
from optparse import OptionParser
from gettext import gettext as _
import gtk
sys.path.insert(0, '/usr/share/disk-manager')
from DiskManager.DiskManager import *
from DiskManager.Config import Config
def main(args, opts) :
if opts.version :
print PACKAGE,VERSION
return
if opts.check :
if Config().get("General", "notify") == "False" :
logging.info("Notify is disable")
return
if probe_new_device() :
Notification()
return
if opts.query :
if not os.getuid() == 0 :
logging.warning("Query database without root privilege.")
logging.warning("Result might be incomplete.\n")
info = get_diskinfo_backend()()
print info.export(opts.query.strip())
return
gtk.window_set_default_icon_name("disk-manager")
if not os.getuid() == 0 :
dialog("warning", _("Insufficient rights"), \
_("You need administrative rights to start this application."))
return
if opts.add :
app = AddWizard()
app.run()
return
if opts.auto :
app = AddWizard(auto = True)
return
app = DiskManager()
app.run()
def get_opt_args() :
parser = OptionParser()
parser.add_option ("-v", "--version", help="show version of the application and exit.", \
action="store_true", dest="version", default=False)
parser.add_option ("-c", "--check", action="store_true",
dest="check", default=False,
help="notify the user for new partitions.")
parser.add_option ("-a", "--add", action="store_true",
dest="add", default=False,
help="configure new detected partitions.")
parser.add_option ("-b", "--auto", action="store_true",
dest="auto", default=False,
help="configure new detected partitions automaticly.")
parser.add_option ("-q", "--query-database", type="string",
dest="query", default="", metavar="DEVICE",
help="query database for DEVICE.\nSet DEVICE to all to print full database.")
parser.add_option ("-d", "--debug", action="store_true",
dest="debug", default=False,
help="print debugging information.")
return parser.parse_args()
if __name__ == '__main__' :
gettext.bindtextdomain("disk-manager",localedir)
gettext.textdomain("disk-manager")
(opts, args) = get_opt_args()
if opts.debug :
level = logging.DEBUG
else :
level = logging.INFO
logging.basicConfig(level=level, format='%(levelname)s : %(message)s')
main(args, opts)
logging.shutdown()
|