Browse Source

qubes: Fix comments accross the code

Acknowledgement:
This commit is a result of core3 review by Marek.
Wojtek Porczyk 9 years ago
parent
commit
92eca8edb9
5 changed files with 12 additions and 17 deletions
  1. 0 12
      qubes/__init__.py
  2. 1 1
      qubes/config.py
  3. 1 2
      qubes/utils.py
  4. 4 0
      qubes/vm/__init__.py
  5. 6 2
      qubes/vm/qubesvm.py

+ 0 - 12
qubes/__init__.py

@@ -547,7 +547,6 @@ class property(object):
 
 
     def __get__(self, instance, owner):
-#       sys.stderr.write('{!r}.__get__({}, {!r})\n'.format(self.__name__, hex(id(instance)), owner))
         if instance is None:
             return self
 
@@ -556,12 +555,10 @@ class property(object):
             raise AttributeError(
                 'qubes.property should be used on qubes.PropertyHolder instances only')
 
-#       sys.stderr.write('  __get__ try\n')
         try:
             return getattr(instance, self._attr_name)
 
         except AttributeError:
-#           sys.stderr.write('  __get__ except\n')
             if self._default is self._NO_DEFAULT:
                 raise AttributeError('property {!r} not set'.format(self.__name__))
             elif isinstance(self._default, collections.Callable):
@@ -761,7 +758,6 @@ class PropertyHolder(qubes.events.Emitter):
         :type load_stage: :py:func:`int` or :py:obj:`None`
         '''
 
-#       sys.stderr.write('{!r}.get_props_list(load_stage={})\n'.format('self', load_stage))
         props = set()
         for class_ in cls.__mro__:
             props.update(prop for prop in class_.__dict__.values()
@@ -769,7 +765,6 @@ class PropertyHolder(qubes.events.Emitter):
         if load_stage is not None:
             props = set(prop for prop in props
                 if prop.load_stage == load_stage)
-#       sys.stderr.write('  props={!r}\n'.format(props))
         return sorted(props, key=lambda prop: (prop.load_stage, prop.order, prop.__name__))
 
 
@@ -829,16 +824,12 @@ class PropertyHolder(qubes.events.Emitter):
         :param lxml.etree._Element xml: XML node reference
         '''
 
-#       sys.stderr.write('<{}>.load_properties(load_stage={}) xml={!r}\n'.format(hex(id(self)), load_stage, self.xml))
-
         self.events_enabled = False
         all_names = set(prop.__name__ for prop in self.get_props_list(load_stage))
-#       sys.stderr.write('  all_names={!r}\n'.format(all_names))
         for node in self.xml.xpath('./properties/property'):
             name = node.get('name')
             value = node.get('ref') or node.text
 
-#           sys.stderr.write('  load_properties name={!r} value={!r}\n'.format(name, value))
             if not name in all_names:
                 raise AttributeError(
                     'No property {!r} found in {!r}'.format(
@@ -848,7 +839,6 @@ class PropertyHolder(qubes.events.Emitter):
 
         self.events_enabled = True
         self.fire_event('property-loaded')
-#       sys.stderr.write('  load_properties return\n')
 
 
     def save_properties(self, with_defaults=False):
@@ -857,7 +847,6 @@ class PropertyHolder(qubes.events.Emitter):
         :param bool with_defaults: If :py:obj:`True`, then it also includes properties which were not set explicite, but have default values filled.
         '''
 
-#       sys.stderr.write('{!r}.save_properties(with_defaults={})\n'.format(self, with_defaults))
 
         properties = lxml.etree.Element('properties')
 
@@ -865,7 +854,6 @@ class PropertyHolder(qubes.events.Emitter):
             try:
                 value = getattr(self, (prop.__name__ if with_defaults else prop._attr_name))
             except AttributeError, e:
-#               sys.stderr.write('AttributeError: {!s}\n'.format(e))
                 continue
 
             try:

+ 1 - 1
qubes/config.py

@@ -4,7 +4,7 @@
 # The Qubes OS Project, http://www.qubes-os.org
 #
 # Copyright (C) 2010  Joanna Rutkowska <joanna@invisiblethingslab.com>
-# Copyright (C) 2014  Wojtek Porczyk <joanna@invisiblethingslab.com>
+# Copyright (C) 2014  Wojtek Porczyk <woju@invisiblethingslab.com>
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License

+ 1 - 2
qubes/utils.py

@@ -23,8 +23,7 @@
 #
 
 
-# FIXME: should be outside of QubesVM?
-def get_timezone(self):
+def get_timezone():
     # fc18
     if os.path.islink('/etc/localtime'):
         return '/'.join(os.readlink('/etc/localtime').split('/')[-2:])

+ 4 - 0
qubes/vm/__init__.py

@@ -586,9 +586,13 @@ class BaseVM(qubes.PropertyHolder):
                 conf["rules"].append(rule)
 
         except EnvironmentError as err:
+            # problem accessing file, like ENOTFOUND, EPERM or sth
+            # return default config
             return conf
+
         except (xml.parsers.expat.ExpatError,
                 ValueError, LookupError) as err:
+            # config is invalid
             print("{0}: load error: {1}".format(
                 os.path.basename(sys.argv[0]), err))
             return None

+ 6 - 2
qubes/vm/qubesvm.py

@@ -416,7 +416,7 @@ class QubesVM(qubes.vm.BaseVM):
             self.maxmem = total_mem_mb/2
 
         # Linux specific cap: max memory can't scale beyond 10.79*init_mem
-        # XXX what?! -woju
+        # see https://groups.google.com/forum/#!topic/qubes-devel/VRqkFj1IOtA
         if self.maxmem > self.memory * 10:
             self.maxmem = self.memory * 10
 
@@ -447,7 +447,6 @@ class QubesVM(qubes.vm.BaseVM):
     # event handlers
     #
 
-
     @qubes.events.handler('property-set:label')
     def on_property_set_label(self, event, name, new_label, old_label=None):
         if self.icon_path:
@@ -557,6 +556,7 @@ class QubesVM(qubes.vm.BaseVM):
             return
 
         try:
+            # TODO: libvirt-ise
             subprocess.check_call(['sudo', system_path["qubes_pciback_cmd"], pci])
             subprocess.check_call(['sudo', 'xl', 'pci-attach', str(self.xid), pci])
         except Exception as e:
@@ -569,6 +569,7 @@ class QubesVM(qubes.vm.BaseVM):
         if not self.is_running():
             return
 
+        # TODO: libvirt-ise
         p = subprocess.Popen(['xl', 'pci-list', str(self.xid)],
                 stdout=subprocess.PIPE)
         result = p.communicate()
@@ -802,6 +803,8 @@ class QubesVM(qubes.vm.BaseVM):
             args += ["-t"]
         if os.isatty(sys.stderr.fileno()):
             args += ["-T"]
+
+        # TODO: QSB#13
         if passio:
             if os.name == 'nt':
                 # wait for qrexec-client to exit, otherwise client is not properly attached to console
@@ -854,6 +857,7 @@ class QubesVM(qubes.vm.BaseVM):
 
         source = 'dom0' if source is None else self.app.domains[source].name
 
+        # XXX TODO FIXME this looks bad...
         if input:
             return self.run("QUBESRPC %s %s" % (service, source),
                         localcmd="echo %s" % input, user=user, wait=True)