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=
"%s" %newStudent
77 db.writeStudent(owd.stickid, owd.getFatUuid(), owd.tattoo(), newStudent)
92 usbDisk.uDisk.__init__(self,path, bus)
93 QObject.__init__(self)
115 fatPath=ff.ensureMounted()
129 f1=
"/usr/share/scolasync/marques.py"
130 f2=os.path.expanduser(markFileName)
131 if os.path.exists(f2):
135 result=eval(open(f,
"r", encoding="utf-8").read())
146 if k
in self.visibleDirs.keys():
160 result=usbDisk.uDisk.headers(locale)
161 ownerProp=QApplication.translate(
"uDisk",
"owner",
None, QApplication.UnicodeUTF8)
162 result.insert(1,ownerProp)
178 return QApplication.translate(
"Dialog",
"inconnu",
None, QApplication.UnicodeUTF8)
188 propListe=usbDisk.uDisk.headers()
199 headers = staticmethod(headers)
211 prompt=QApplication.translate(
"Dialog",
"La cle {id}<br>n'est pas identifiee, donnez le nom du proprietaire",
None, QApplication.UnicodeUTF8).format(id=self.
stickid)
212 title=QApplication.translate(
"Dialog",
"Entrer un nom",
None, QApplication.UnicodeUTF8)
213 text,ok = QInputDialog.getText(
None, title, prompt)
214 if ok
and len(text)>0
and not db.hasStudent(text):
236 def __init__(self, access="disk", diskClass=uDisk, diskDict=None, noLoop=True):
238 usbDisk.Available.__init__(self, access, diskClass, diskDict)
247 for d
in self.disks.keys():
248 d.owner=d.ensureOwner(self.
noLoop)
251 if __name__==
"__main__":