7 this file is part of the project scolasync
9 Copyright (C) 2010 Georges Khaznadar <georgesk@ofset.org>
11 This program is free software: you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version3 of the License, or
14 (at your option) any later version.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program. If not, see <http://www.gnu.org/licenses/>.
27 import os.path, dbus, subprocess, time
30 from globaldef
import markFileName
33 liste statique pour éviter de demander chaque seconde le nom d'un
34 propriétaire de clé si on n'a pas souhaité le donner.
45 tattooFileName = os.path.join(mountPoint,
".scolasync-tattoo")
47 if os.path.exists(tattooFileName):
48 tattoo_=open(tattooFileName,
"r").readlines()[0].strip()
53 tattoo_=
"%12.2f" %time.time()
59 outfile=open(tattooFileName,
"w")
60 outfile.write(tattoo_)
72 title=QApplication.translate(
"Dialog",
"Choix du propriétaire",
None, QApplication.UnicodeUTF8)
73 prompt=QApplication.translate(
"Dialog",
"Nouveau nom du propriétaire du baladeur",
None, QApplication.UnicodeUTF8)
74 newStudent, ok = QInputDialog.getText(
None, title, prompt, text=hint)
76 newStudent=
u"%s" %newStudent
77 db.writeStudent(owd.stickid, owd.getFatUuid(), owd.tattoo(), newStudent)
92 def __init__(self, path, bus, checkable=False):
93 usbDisk.uDisk.__init__(self,path, bus, checkable)
94 QObject.__init__(self)
116 fatPath=ff.ensureMounted()
130 f1=
"/usr/share/scolasync/marques.py"
131 f2=os.path.expanduser(markFileName)
132 if os.path.exists(f2):
136 result=eval(open(f,
"r").read())
147 if k
in self.visibleDirs.keys():
162 result=usbDisk.uDisk.headers(checkable, locale)
163 ownerProp=QApplication.translate(
"uDisk",
"owner",
None, QApplication.UnicodeUTF8)
164 result.insert(1,ownerProp)
180 return QApplication.translate(
"Dialog",
"inconnu",
None, QApplication.UnicodeUTF8)
191 propListe=usbDisk.uDisk.headers()
212 headers = staticmethod(headers)
224 prompt=QApplication.translate(
"Dialog",
"La cle %1<br>n'est pas identifiee, donnez le nom du proprietaire",
None, QApplication.UnicodeUTF8).arg(self.
stickid)
225 title=QApplication.translate(
"Dialog",
"Entrer un nom",
None, QApplication.UnicodeUTF8)
226 text,ok = QInputDialog.getText(
None, title, prompt)
227 text =
u"%s" %text.toUtf8()
228 if ok
and len(text)>0
and not db.hasStudent(text):
251 def __init__(self, checkable=False, access="disk", diskClass=uDisk, diskDict=None, noLoop=True):
253 usbDisk.Available.__init__(self, checkable, access, diskClass, diskDict)
262 for d
in self.disks.keys():
263 d.owner=d.ensureOwner(self.
noLoop)