ScolaSync  5.1
usbDisk2.py
Aller à la documentation de ce fichier.
1 # $Id: usbDisk2.py 36 2014-03-16 19:37:27Z georgesk $
2 
3 licence={}
4 licence_en="""
5  file usbDisk2.py
6  this file is part of the project scolasync. It is a rewrite of
7  usbDisk.py to take in account udisks2.
8 
9  Copyright (C) 2014 Georges Khaznadar <georgesk@ofset.org>
10 
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.
15 
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.
20 
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/>.
23 """
24 
25 licence['en']=licence_en
26 dependances="python3-dbus python3-dbus.mainloop.pyqt5"
27 
28 
29 import dbus, subprocess, os, os.path, re, time, threading, logging, inspect
30 from dbus.mainloop.glib import DBusGMainLoop, threads_init
31 from gi.repository import Gio, GLib, UDisks
32 from PyQt5.QtWidgets import *
33 
34 
35 debug=False
37  return ""
38 
39 if debug :
40  logging.basicConfig(level=logging.DEBUG)
41  def inspectData():
42  caller=1
43  callerframerecord = inspect.stack()[caller]
44  frame = callerframerecord[0]
45  info = inspect.getframeinfo(frame)
46  return " -- file={0}, function={1}, line={2}".format(
47  info.filename, info.function, info.lineno
48  )
49 else:
50  pass
51  # logging.basicConfig(level=logging.NOTSET)
52 
53 
54 
55 
58 
59 def safePath(obj):
60  if type(obj)==type(""):
61  path=obj
62  else:
63  path= obj.get_object_path()
64  posUnderscore=path.rfind("_")
65  posSlash=path.rfind("/")
66  if posUnderscore > posSlash: # il faut retirer tout après l'underscore final
67  path=path[:posUnderscore]
68  return path
69 
70 
73 
74 def fs_size(device):
75  try:
76  stat = os.statvfs(device)
77  except:
78  return (0, 0)
79  free = stat.f_bsize * stat.f_bavail # les blocs réservés sont inclus
80  total = stat.f_bsize * stat.f_blocks
81  return (total, free)
82 
83 
84 
86 no_options = GLib.Variant('a{sv}', {})
87 
89 
90 
91 not_interesting = (
92  # boucle
93  '/org/freedesktop/UDisks2/block_devices/loop',
94  # disque raid
95  '/org/freedesktop/UDisks2/block_devices/dm_',
96  # mémoire vive
97  '/org/freedesktop/UDisks2/block_devices/ram',
98  '/org/freedesktop/UDisks2/block_devices/zram',
99  # disques durs
100  '/org/freedesktop/UDisks2/drives/',
101  )
102 
103 # Cette classe a été inspirée par le projet USBcreator.
104 # Plusieurs modifications ont été faites au code original.
105 # Les fonctions de rappel ne tiennent compte que des périphériques USB
106 #
107 
109 
114 
115  def __init__(self, logger=logging, diskClass=object):
116  self.install_thread = None
117  self.logger=logger
118 
120  self.diskClass=diskClass
121  self.targets = {}
122 
124  self.modified=False
125  DBusGMainLoop(set_as_default=True)
126  threads_init()
127  self.bus = dbus.SystemBus()
128  self.udisks = UDisks.Client.new_sync(None)
129  self.manager = self.udisks.get_object_manager()
130  self.cbHooks = {
131  'object-added': {
132  'profile': ['man', 'obj'],
133  'hooks' : []
134  },
135  'object-removed': {
136  'profile': ['man', 'obj'],
137  'hooks' : []
138  },
139  'interface-added': {
140  'profile': ['man', 'obj'],
141  'hooks' : []
142  },
143  'interface-removed': {
144  'profile': ['man', 'obj'],
145  'hooks' : []
146  },
147  'interface-proxy-properties-changed': {
148  'profile': ['man', 'obj', 'interface'],
149  'hooks' : []
150  },
151  }
152  # mise en place des fonctions de rappel à utiliser pour tout changement
153  self.addHook('object-added',
154  lambda man, obj: self._udisks_obj_added(obj))
155  self.addHook('object-removed',
156  lambda man, obj: self._udisks_obj_removed(obj))
157  self.addHook('interface-added',
158  lambda man, obj, iface: self._device_changed(obj))
159  self.addHook('interface-removed',
160  lambda man, obj, iface: self._device_changed(obj))
161  self.addHook('interface-proxy-properties-changed',
162  lambda man, obj, iface, props, invalid: self._device_changed(obj))
163 
164  # ajoute une fonction à appeler pour un signal nommé, et enregistre
165  # cette fonction dans self.cbHooks, après vérification de sa liste
166  # de paramètres.
167  # @param signal une chaîne
168  # @param func une fonction
169  # @return le résultat de l'appel à self.manager.connect(signal,func)
170  #
171 
172  def addHook(self, signal, func):
173  if inspect.getargspec(func).args == self.cbHooks[signal]['profile']:
174  cb=self.manager.connect(signal,func)
175  self.cbHooks[signal]['hooks'].append(cb)
176  return cb
177  return None
178 
179  # voir le fichier integration-test issu des sources de udisks2
180  # Essaie de monter un système de fichier jusqu'à ce qu'il
181  # cesse d'échouer avec "Busy", ou que l'erreur soit "déjà monté".
182  # Échoue si l'erreur est autre que les deux précédentes.
183  # @param fs un système de fichier à monter
184  # @param timeout nombre de secondes d'attente au maximum
185  # @param retryDelay délai entre deux essais
186  #
187 
188  def retry_mount(self, fs, timeout=5, retryDelay=0.3):
189  while timeout >= 0:
190  try:
191  return fs.call_mount_sync(no_options, None)
192  except GLib.GError as e:
193  if 'UDisks2.Error.AlreadyMounted' in e.message:
194  m=re.match(r".*already mounted[^/]*([^\']+).*",e.message)
195  return m.group(1)
196  elif 'UDisks2.Error.DeviceBusy' in e.message:
197  pass
198  else:
199  raise
200  time.sleep(retryDelay)
201  timeout -= retryDelay
202  return ''
203 
204 
206 
207  def detect_devices(self):
208  for obj in self.manager.get_objects():
209  self._udisks_obj_added(obj)
210 
211 
218 
219  def _interesting_obj(self, obj):
220  interesting=False
221  drive=None
222  partition=None
223 
224  # ne tient pas compte des périphériques non débranchables
225  path = safePath(obj)
226  for boring in not_interesting:
227  if path.startswith(boring):
228  return interesting, drive, partition
229 
230  # ne considère que les périphériques de type block
231  block = obj.get_block()
232  if not block:
233  return interesting, drive, partition
234 
235  # initialise drive, nom du disque ?
236  drive_name = block.get_cached_property('Drive').get_string()
237  if drive_name == '/':
238  return interesting, drive, partition
239  else:
240  drive = self.udisks.get_object(drive_name).get_drive()
241 
242  # on ne tient pas compte des CDROMS ni DVDROMS
243  if drive and drive.get_cached_property('Optical').get_boolean():
244  return interesting, drive, partition
245 
246  interesting=True
247  # détermine si on a un disque ou une partition
248  partition = obj.get_partition()
249  return interesting, drive, partition
250 
251 
256 
257  def _udisks_obj_added(self, obj):
258  interesting, drive, part = self._interesting_obj(obj)
259  if part:
260  self._udisks_partition_added(obj, drive, part)
261  elif drive:
262  self._udisks_drive_added (obj, drive, part)
263  return
264 
265 
269 
270  def objIsUsb(self,obj):
271  for s in obj.get_block().get_cached_property('Symlinks'):
272  if b'/dev/disk/by-id/usb' in bytes(s):
273  return True
274  return False
275 
276  # Fonction de rappel pour l'ajout d'une partition,
277  # met à jour self.targets
278  # @param obj une instance de UDisksObjectProxy
279  # @param drive une instance de ...
280  # @param partition une instance de ...
281  #
282  #
283  # @protected
284 
285  def _udisks_partition_added(self, obj, drive, partition):
286  path = safePath(obj)
287  block = obj.get_block()
288  self.logger.debug(QApplication.translate("uDisk","Partition ajoutée %s",None) % path+inspectData())
289  fstype = block.get_cached_property('IdType').get_string()
290  parent = partition.get_cached_property('Table').get_string()
291  total = drive.get_cached_property('Size').get_uint64()
292  free = -1
293  mount = ''
294  fs = obj.get_filesystem()
295  if fs:
296  mount_points = fs.get_cached_property('MountPoints').get_bytestring_array()
297  if len(mount_points)>0:
298  mount= mount_points[0]
299  if not mount and fstype == 'vfat':
300  try:
301  mount = self.retry_mount(fs)
302  except:
303  logging.exception(QApplication.translate("uDisk","Échec au montage du disque : %s",None) % path)
304  if mount:
305  total, free = fs_size(mount)
306  isUsb=self.objIsUsb(obj)
307  if not isUsb:
308  self.logger.debug(QApplication.translate("uDisk","On n'ajoute pas le disque : partition non-USB",None)+inspectData())
309  elif total < 1:
310  self.logger.debug(QApplication.translate("uDisk","On n'ajoute pas le disque : partition vide",None)+inspectData())
311  else:
312  udisk=self.diskClass(
313  path=path, mp=mount, isUsb=isUsb,
314  vendor=drive.get_cached_property('Vendor').get_string(),
315  model=drive.get_cached_property('Model').get_string(),
316  parent=safePath(parent),
317  fstype=fstype,
318  serial=block.get_cached_property('Drive').get_string().split('_')[-1],
319  uuid=block.get_cached_property('IdUUID').get_string(),
320  free=free,
321  capacity=total,
322  device=block.get_cached_property('Device').get_bytestring().decode('utf-8'),
323  )
324  self.targets[path] = udisk
325  self.modified=True
326  return
327 
328  def _udisks_drive_added(self, obj, drive, part):
329  path = safePath(obj)
330  block = obj.get_block()
331  if path in self.targets:
332  self.logger.debug(QApplication.translate("uDisk","Disque déjà ajouté auparavant : %s",None) % path+inspectData())
333  return
334  self.logger.debug(QApplication.translate("uDisk","Disque ajouté : %s",None) % path+inspectData())
335  size = drive.get_cached_property('Size').get_uint64()
336 
338  """
339  if size <= 0:
340  self.logger.debug(QApplication.translate("uDisk","On n'ajoute pas le disque : partition à 0 octets.",None)+inspectData())
341  return
342  """
343  isUsb = self.objIsUsb(obj)
344  if not isUsb:
345  self.logger.debug(QApplication.translate("uDisk","On n'ajoute pas le disque : partition non-USB",None)+inspectData())
346  else:
347  udisk=self.diskClass(
348  path=path,
349  isUsb=isUsb,
350  parent='',
351  vendor=drive.get_cached_property('Vendor').get_string(),
352  model=drive.get_cached_property('Model').get_string(),
353  serial=block.get_cached_property('Drive').get_string().split('_')[-1],
354  uuid=block.get_cached_property('IdUUID').get_string(),
355  capacity=size,
356  device=block.get_cached_property('Device').get_bytestring().decode('utf-8'),
357  )
358  self.targets[path] =udisk
359  self.modified=True
360  return
361 
362  def _device_changed(self, obj):
363  path = safePath(obj)
364  self.logger.debug(QApplication.translate("uDisk","Changement pour le disque %s",None) % path+inspectData())
365 
366  # Fonction de rappel déclenchée par le retrait d'un disque.
367  # Met à jour self.targets
368  # @param obj une instance de UDisksObjectProxy
369  #
370  #
371  # @protected
372 
373  def _udisks_obj_removed(self, obj):
374  path=safePath(obj)
375  logging.debug(QApplication.translate("uDisk","Disque débranché du système : %s",None) % path)
376  if path in self.targets:
377  self.targets.pop(path)
378  self.modified=True
379 
380 
389 
390 class uDisk2:
391 
392 
409 
410  def __init__(self, path, mp='', isUsb=False, vendor='', model='', parent=None,
411  fstype='', serial='', uuid='',
412  free=0, capacity=0, device='', firstFat=None, selected=True):
413  self.path=path
414  self.mp=mp
415  self.isUsb=isUsb
416  self.vendor=vendor
417  self.model=model
418  self.parent=parent
419  self.fstype=fstype
420  self.stickid=serial
421  self.uuid=uuid
422  self.free=free
423  self.capacity=capacity
424  self.devStuff=device
425  self.firstFat=firstFat
426  self.selected=selected
427  self.rlock=threading.RLock()
428  return
429 
430 
433  _itemNames={
434  "1mp":QApplication.translate("uDisk","point de montage",None),
435  "2capacity":QApplication.translate("uDisk","taille",None),
436  "3vendor":QApplication.translate("uDisk","marque",None),
437  "4model":QApplication.translate("uDisk","modèle de disque",None),
438  "5stickid":QApplication.translate("uDisk","numéro de série",None),
439  }
440 
441 
444  _specialItems={"0Check":QApplication.translate("uDisk","cocher",None)}
445 
446 
449  _ItemPattern=re.compile("[0-9]?(.*)")
450 
451  # renvoie un identifiant unique. Dans cette classe, cette fonction
452  # est synonyme de file()
453  # @return un identifiant unique, garanti par le système de fichiers
454  #
455 
456  def uniqueId(self):
457  return self.file()
458 
459  # Méthode statique, pour avoir des titres de colonne.
460  # renvoie des titres pour les items obtenus par __getitem__.
461  # @param locale la locale, pour traduire les titres éventuellement.
462  # Valeur par défaut : "C"
463  # @return une liste de titres de colonnes
464  #
465 
466  def headers(locale="C"):
467  result= list(uDisk2._specialItems.keys())+ list(uDisk2._itemNames.keys())
468  return sorted(result)
469 
470  headers = staticmethod(headers)
471 
472 
475 
476  def __str__(self):
477  return self.title()+self.valuableProperties()
478 
479 
482 
483  def title(self):
484  return self.path
485 
486 
489 
490  def isDosFat(self):
491  return self.fstype=="vfat"
492 
493 
495 
496  def isMounted(self):
497  return bool(self.mp)
498 
499 
502 
503  def valuableProperties(self,indent=4):
504  prefix="\n"+" "*indent
505  r=""
506  props=["mp", "parent", "fstype", "stickid", "uuid", "vendor", "model", "devStuff", "free", "capacity"]
507  for prop in props:
508  r+=prefix+"%s = %s" %(prop, getattr(self,prop))
509  return r
510 
511 
513 
514  def mountPoint(self):
515  return self.mp
516 
517  # retire le numéro des en-têtes pour en faire un nom de propriété
518  # valide pour interroger dbus
519  # @param n un numéro de propriété qui se réfère aux headers
520  # @return une propriété renvoyée par dbus, dans un format imprimable
521  #
522 
523  def unNumberProp(self,n):
524  m=uDisk2._ItemPattern.match(self.headers()[n])
525  try:
526  return getattr(self, m.group(1))
527  except:
528  return ""
529 
530 
536 
537  def __getitem__(self,n):
538  propListe=self.headers()
539  if n==0:
540  return self.selected
541  elif n <= len(propListe):
542  return self.unNumberProp(n-1)
543 
544 
547 
548  def ensureMounted(self):
549  mount_paths=self.mp
550  if mount_paths==None: # le cas où la notion de montage est hors-sujet
551  return ""
552  leftTries=5
553  while len(mount_paths)==0 and leftTries >0:
554  leftTries = leftTries - 1
555  path=self.path
556  if len(path)>0:
557  subprocess.call("udisks --mount %s > /dev/null" %path,shell=True)
558  paths=self.mp
559  print("STILL TO DEBUG: is the mount OK? is self.mp updated?")
560  if paths:
561  return paths
562  else:
563  time.sleep(0.5)
564  else:
565  time.sleep(0.5)
566  if leftTries==0:
567  raise Exception ("Could not mount the VFAT after 5 tries.")
568  else:
569  return mount_paths
570 
571 
572 
573 
582 
584 
585 
591 
592  def __init__(self, access="disk", diskClass=uDisk2):
593  UDisksBackend.__init__(self, diskClass=diskClass)
594  self.access=access
595  self.detect_devices()
596  self.finishInit()
597 
598 
600 
601  def finishInit(self):
602  self.mountFirstFats()
603 
604  # fabrique la liste des partitions FAT,
605  # monte les partitions FAT si elles ne le sont pas
606  #
607 
608  def mountFirstFats(self):
609  self.firstFats = self.getFirstFats()
610  if self.access=="firstFat":
611  for p in self.firstFats:
612  uDisk2(p,self).ensureMounted()
613 
614 
616 
617  def __trunc__(self):
618  return len(self.firstFats)
619 
620  # Sert à comparer deux collections de disques, par exemple
621  # une collection passée et une collection présente.
622  # @param other une instance de Available
623  # @return vrai si other semble être la même collection de disques USB
624  #
625 
626  def compare(self, other):
627  result=self.summary()==other.summary()
628  return result
629 
630 
634 
635  def contains(self, ud):
636  return ud.path in self.targets
637 
638 
641 
642  def disks(self):
643  return [d for d in self.targets if not self.targets[d].parent]
644 
645 
649 
650  def parts(self, d):
651  return [p for p in self.targets if self.targets[p].parent==d]
652 
653 
656 
657  def disks_ud(self):
658  return [self.targets[d] for d in self.targets if not self.targets[d].parent]
659 
660 
665 
666  def parts_ud(self, d):
667  return [self.targets[p] for p in self.targets if self.targets[p].parent==d]
668 
669 
672 
673  def summary(self):
674  r= "Available USB disks\n"
675  r+= "===================\n"
676  for d in sorted(self.disks()):
677  r+="%s\n" %(self.targets[d].devStuff)
678  partlist=self.parts(d)
679  if len(partlist)>0:
680  r+=" Partitions :\n"
681  for part in partlist:
682  r+=" %s\n" %(self.targets[part].devStuff,)
683  return r
684 
685 
688 
689  def __str__(self):
690  r= "Available USB disks\n"
691  r+= "===================\n"
692  for d in self.disks():
693  r+="%s\n" %d
694  partlist=self.parts(d)
695  if len(partlist)>0:
696  r+=" Partitions :\n"
697  for part in sorted(partlist):
698  r+=" %s\n" %(self.targets[part].devStuff)
699  r+=self.targets[part].valuableProperties(12)+"\n"
700  return r
701 
702  # Renvoye le nième disque. Le fonctionnement dépend du paramètre
703  # self.access
704  # @param n un numéro
705  # @return le nième disque USB connecté sous forme d'instance de uDisk2
706  #
707 
708  def __getitem__(self, n):
709  if self.access=="disk":
710  path=self.targets.keys()[n]
711  elif self.access=="firstFat":
712  path=self.firstFats[n]
713  return self.targets[path]
714 
715  # Renseigne sur la longueur de la collection. Le fonctionnement
716  # dépend du paramètre self.access
717  # @return la longueur de la collection de disques renvoyée
718  #
719 
720  def __len__(self):
721  if self.access=="disk":
722  return len(self.targets)
723  elif self.access=="firstFat":
724  return len(self.firstFats)
725 
726  # Facilite l'accès aux partitions de type DOS-FAT, et a des effets
727  # de bord :
728  # * marque la première vfat dans chaque instance de disque
729  # * construit une liste des chemins uDisk des FATs
730  # @return une liste de partitions, constituée de la première
731  # partition de type FAT de chaque disque USB connecté
732  #
733 
734  def getFirstFats(self):
735  result=[]
736  disks=[d for d in self.targets if not self.targets[d].parent]
737  for d in disks:
738  parts=[p for p in self.targets if self.targets[p].parent==d]
739  for p in parts:
740  if self.targets[p].fstype=="vfat":
741  result.append(p)
742  # inscrit l'information dans l'instance du disque, par effet de bord
743  self.targets[d].firstFat=self.targets[p]
744  return result
745 
746 
749 
750  def hasDev(self, dev):
751  s=str(dev)
752  for p in self.fatPaths:
753  if p.split("/")[-1]==s:
754  return True
755  return False
756 
757 
758 
759 
760 
761 if __name__=="__main__":
762  from PyQt5.QtCore import *
763  from PyQt5.QtGui import *
764  import sys
766  def __init__(self):
767  QMainWindow.__init__(self)
768 
769  # The only thing in the app is a quit button
770  quitbutton = QPushButton('Examinez le terminal\nbranchez et débranchez des clés USB, puis\nQuittez', self)
771  quitbutton.clicked.connect(self.close)
772  self.setCentralWidget(quitbutton)
773 
774 
775  machin=Available()
776  print (machin)
777  def print_targets_if_modif(man, obj):
778  if machin.modified:
779  print([s.split("/")[-1] for s in machin.targets.keys()])
780  machin.modified=False
781  machin.addHook('object-added', print_targets_if_modif)
782  machin.addHook('object-removed', print_targets_if_modif)
783 
784  app = QApplication(sys.argv)
785  main = MainWindow()
786  main.show()
787  sys.exit(app.exec_())
src.usbDisk2.uDisk2.unNumberProp
def unNumberProp(self, n)
Definition: usbDisk2.py:523
src.usbDisk2.safePath
def safePath(obj)
Récupère de façon sûre le path d'une instance de UDisksObjectProxy.
Definition: usbDisk2.py:59
src.usbDisk2.uDisk2.ensureMounted
def ensureMounted(self)
Permet de s'assurer qu'une partition ou un disque sera bien monté
Definition: usbDisk2.py:548
src.usbDisk2.uDisk2.uuid
uuid
Definition: usbDisk2.py:419
src.usbDisk2.UDisksBackend._interesting_obj
def _interesting_obj(self, obj)
trouve si un objet est intéressant à cataloguer
Definition: usbDisk2.py:219
src.usbDisk2.Available.firstFats
firstFats
Definition: usbDisk2.py:609
src.usbDisk2.Available.getFirstFats
def getFirstFats(self)
Definition: usbDisk2.py:734
src.usbDisk2.uDisk2.rlock
rlock
Definition: usbDisk2.py:425
src.usbDisk2.UDisksBackend.__init__
def __init__(self, logger=logging, diskClass=object)
Le constructeur.
Definition: usbDisk2.py:115
src.usbDisk2.UDisksBackend.bus
bus
Definition: usbDisk2.py:127
src.usbDisk2.uDisk2.stickid
stickid
Definition: usbDisk2.py:418
src.usbDisk2.UDisksBackend._udisks_obj_removed
def _udisks_obj_removed(self, obj)
Definition: usbDisk2.py:373
src.usbDisk2.Available.__getitem__
def __getitem__(self, n)
Definition: usbDisk2.py:708
src.usbDisk2.MainWindow
Definition: usbDisk2.py:765
src.usbDisk2.UDisksBackend._udisks_partition_added
def _udisks_partition_added(self, obj, drive, partition)
Definition: usbDisk2.py:285
src.usbDisk2.MainWindow.__init__
def __init__(self)
Definition: usbDisk2.py:766
src.usbDisk2.inspectData
def inspectData()
Definition: usbDisk2.py:36
src.usbDisk2.Available
une classe pour représenter la collection des disques USB connectés
Definition: usbDisk2.py:583
src.usbDisk2.UDisksBackend.install_thread
install_thread
Definition: usbDisk2.py:116
src.usbDisk2.uDisk2.free
free
Definition: usbDisk2.py:420
src.usbDisk2.Available.summary
def summary(self)
Fournit une représentation imprimable d'un résumé
Definition: usbDisk2.py:673
src.usbDisk2.Available.disks_ud
def disks_ud(self)
Récolte les enregistrements de niveau supérieur de self.targets.
Definition: usbDisk2.py:657
src.usbDisk2.uDisk2.isUsb
isUsb
Definition: usbDisk2.py:413
src.usbDisk2.uDisk2.isDosFat
def isDosFat(self)
Permet de reconnaitre les partitions DOS-FAT.
Definition: usbDisk2.py:490
src.usbDisk2.UDisksBackend.manager
manager
Definition: usbDisk2.py:129
src.usbDisk2.uDisk2.__init__
def __init__(self, path, mp='', isUsb=False, vendor='', model='', parent=None, fstype='', serial='', uuid='', free=0, capacity=0, device='', firstFat=None, selected=True)
Le constructeur.
Definition: usbDisk2.py:410
src.usbDisk2.uDisk2.title
def title(self)
Permet d'obtenir un identifiant unique de disque.
Definition: usbDisk2.py:483
src.usbDisk2.Available.__str__
def __str__(self)
Fournit une représentation imprimable.
Definition: usbDisk2.py:689
src.usbDisk2.UDisksBackend.logger
logger
Definition: usbDisk2.py:117
src.usbDisk2.uDisk2.parent
parent
Definition: usbDisk2.py:416
src.usbDisk2.Available.compare
def compare(self, other)
Definition: usbDisk2.py:626
src.usbDisk2.UDisksBackend
Definition: usbDisk2.py:108
src.usbDisk2.Available.finishInit
def finishInit(self)
Fin de l'initialisation.
Definition: usbDisk2.py:601
src.usbDisk2.Available.__init__
def __init__(self, access="disk", diskClass=uDisk2)
Le constructeur.
Definition: usbDisk2.py:592
src.usbDisk2.UDisksBackend.detect_devices
def detect_devices(self)
Fait un inventaire des disques.
Definition: usbDisk2.py:207
src.usbDisk2.fs_size
def fs_size(device)
Renvoie la taille d'un système de fichier et la place disponible.
Definition: usbDisk2.py:74
src.usbDisk2.uDisk2.mountPoint
def mountPoint(self)
Definition: usbDisk2.py:514
src.usbDisk2.uDisk2.model
model
Definition: usbDisk2.py:415
src.usbDisk2.UDisksBackend.diskClass
diskClass
self.targets est un dictionnaire des disques détectés les clés sont les paths et les contenus des ins...
Definition: usbDisk2.py:120
src.usbDisk2.uDisk2.fstype
fstype
Definition: usbDisk2.py:417
src.usbDisk2.uDisk2.isMounted
def isMounted(self)
Definition: usbDisk2.py:496
src.usbDisk2.Available.mountFirstFats
def mountFirstFats(self)
Definition: usbDisk2.py:608
src.usbDisk2.uDisk2.__str__
def __str__(self)
Fournit une représentation imprimable.
Definition: usbDisk2.py:476
src.usbDisk2.uDisk2.valuableProperties
def valuableProperties(self, indent=4)
Facilite l'accès aux propriétés intéressantes d'une instance.
Definition: usbDisk2.py:503
src.usbDisk2.UDisksBackend._udisks_obj_added
def _udisks_obj_added(self, obj)
Fonction de rappel pour les ajouts de disque.
Definition: usbDisk2.py:257
src.usbDisk2.debug
bool debug
activate debugging #######################
Definition: usbDisk2.py:35
QMainWindow
src.usbDisk2.uDisk2.mp
mp
Definition: usbDisk2.py:412
src.usbDisk2.UDisksBackend.addHook
def addHook(self, signal, func)
Definition: usbDisk2.py:172
src.usbDisk2.uDisk2.vendor
vendor
Definition: usbDisk2.py:414
src.usbDisk2.UDisksBackend.modified
modified
self.modified signifie une modification récente, à prendre en compte par une application au niveau ut...
Definition: usbDisk2.py:124
src.usbDisk2.Available.access
access
Definition: usbDisk2.py:594
src.usbDisk2.uDisk2.firstFat
firstFat
Definition: usbDisk2.py:423
QtCore
src.usbDisk2.Available.__trunc__
def __trunc__(self)
Definition: usbDisk2.py:617
src.usbDisk2.Available.disks
def disks(self)
Récolte les enregistrements de niveau supérieur de self.targets.
Definition: usbDisk2.py:642
src.usbDisk2.uDisk2.path
path
Definition: usbDisk2.py:411
src.usbDisk2.Available.parts
def parts(self, d)
Récolte les partitions d'un disque.
Definition: usbDisk2.py:650
src.usbDisk2.uDisk2
une classe pour représenter un disque ou une partition.
Definition: usbDisk2.py:390
src.usbDisk2.UDisksBackend.cbHooks
cbHooks
Definition: usbDisk2.py:130
src.usbDisk2.uDisk2.headers
headers
Definition: usbDisk2.py:470
src.usbDisk2.Available.hasDev
def hasDev(self, dev)
Definition: usbDisk2.py:750
src.usbDisk2.uDisk2.__getitem__
def __getitem__(self, n)
Renvoie un élément de listage de données internes au disque.
Definition: usbDisk2.py:537
src.usbDisk2.UDisksBackend._device_changed
def _device_changed(self, obj)
Definition: usbDisk2.py:362
src.usbDisk2.uDisk2.uniqueId
def uniqueId(self)
Definition: usbDisk2.py:456
src.usbDisk2.uDisk2.selected
selected
Definition: usbDisk2.py:424
src.usbDisk2.uDisk2.capacity
capacity
Definition: usbDisk2.py:421
src.usbDisk2.UDisksBackend._udisks_drive_added
def _udisks_drive_added(self, obj, drive, part)
Definition: usbDisk2.py:328
QtGui
src.usbDisk2.Available.contains
def contains(self, ud)
Permet de déterminer si un disque est dans la collection.
Definition: usbDisk2.py:635
QtWidgets
src.usbDisk2.Available.__len__
def __len__(self)
Definition: usbDisk2.py:720
src.usbDisk2.uDisk2.devStuff
devStuff
Definition: usbDisk2.py:422
src.usbDisk2.UDisksBackend.udisks
udisks
Definition: usbDisk2.py:128
src.usbDisk2.UDisksBackend.targets
targets
Definition: usbDisk2.py:121
src.usbDisk2.UDisksBackend.retry_mount
def retry_mount(self, fs, timeout=5, retryDelay=0.3)
Definition: usbDisk2.py:188
src.usbDisk2.Available.parts_ud
def parts_ud(self, d)
Récolte les partitions d'un disque.
Definition: usbDisk2.py:666
src.usbDisk2.UDisksBackend.objIsUsb
def objIsUsb(self, obj)
détermine si un périphérique est de type USB
Definition: usbDisk2.py:270
src.usbDisk2.print_targets_if_modif
def print_targets_if_modif(man, obj)
Definition: usbDisk2.py:777