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
|
#! @PYTHON@ @PYOPTIONS@
# -*- python -*-
# -*- coding: UTF-8 -*-
#
# ntfs-config : NTFS Configuration Tool
# 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 gtk
import gettext
from optparse import OptionParser
from gettext import gettext as _
# Hack to make sure that path is set correctly when installation is in /usr/local
if "/usr/local" in sys.argv[0] :
for path in sys.path :
if "/usr/lib/python" in path :
local_path = path.replace("/usr", "/usr/local")
if not local_path in sys.path :
sys.path.append(path.replace("/usr", "/usr/local"))
from NtfsConfig.NtfsConfig import *
from NtfsConfig.Config import Config
def main(args, opts) :
if opts.version :
print PACKAGE,VERSION
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("gnome-dev-harddisk")
if not os.getuid() == 0 :
dialog("warning", _("Insufficient rights"), \
_("You need administrative rights to start this application."))
return
# Check for ntfs-3g
info = get_diskinfo_backend()()
if not "ntfs-3g" in info.get_drivers("ntfs")["all"].keys() :
dialog("error", _("Read/Write NTFS driver not installed"), \
_("In order to enable write support for your NTFS devices, "
"you'll need first to install the ntfs-3g driver.\n"
"If your distribution don't provide it, you can get it from :\n"
"http://www.ntfs-3g.org"))
return
app = NtfsConfig()
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 ("-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("ntfs-config",localedir)
gettext.textdomain("ntfs-config")
(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()
|