Example #1
0
def _get_js_config_file(device_type):
    """
    Returns the filename used for saving the joystick calibration file

    If the directory that should own the file doesn't exist, it will be
    created.

    Keyword arguments:
    device_type    --    device_type
    """
    g15os.mkdir_p(g15globals.user_config_dir)
    return os.path.join(g15globals.user_config_dir, "%s.js" % device_type)
Example #2
0
def _get_js_config_file(device_type):
    """
    Returns the filename used for saving the joystick calibration file

    If the directory that should own the file doesn't exist, it will be
    created.

    Keyword arguments:
    device_type    --    device_type
    """
    g15os.mkdir_p(g15globals.user_config_dir)
    return os.path.join(g15globals.user_config_dir, "%s.js" % device_type)
Example #3
0
 def load(self):
     accounts = []
     if not os.path.exists(self._conf_file):
         dir_path = os.path.dirname(self._conf_file)
         g15os.mkdir_p(dir_path)
     else:
         document = etree.parse(self._conf_file)        
         for element in document.getroot().xpath('//%s' % self.item_name):
             acc = G15Account(element.get("name"), element.get("type"))
             for property_element in element:
                 acc.properties[property_element.get("name")] = property_element.get("value") 
             accounts.append(acc)
             
     self.accounts = accounts
Example #4
0
active_profile = None
conf_client = gconf.client_get_default()
    
'''
Watch for changes in macro configuration directory.
Observers can add a callback function to profile_listeners
to be informed when macro profiles change
'''
profile_listeners = []

wm = pyinotify.WatchManager()
mask = pyinotify.IN_DELETE | pyinotify.IN_MODIFY | pyinotify.IN_CREATE | pyinotify.IN_ATTRIB  # watched events

# Create macro profiles directory
conf_dir = os.path.join(g15globals.user_config_dir, "macro_profiles")
g15os.mkdir_p(conf_dir)

class EventHandler(pyinotify.ProcessEvent):
    """
    Event handle the listens for the inotify events and informs all callbacks
    that are registered in the profile_listeners variable
    """
    
    def _get_profile_ids(self, event):
        path = os.path.basename(event.pathname)
        device_uid = os.path.basename(os.path.dirname(event.pathname))
        if path.endswith(".macros") and not path.startswith("."):
            id_no = path.split(".")[0]
            return ( id_no, device_uid )
    
    def _notify(self, event):
Example #5
0
active_profile = None

conf_client = gconf.Client.get_default()
"""
Watch for changes in macro configuration directory.
Observers can add a callback function to profile_listeners
to be informed when macro profiles change
"""
profile_listeners = []

wm = pyinotify.WatchManager()
mask = pyinotify.IN_DELETE | pyinotify.IN_MODIFY | pyinotify.IN_CREATE | pyinotify.IN_ATTRIB  # watched events

# Create macro profiles directory
conf_dir = os.path.join(g15globals.user_config_dir, "macro_profiles")
g15os.mkdir_p(conf_dir)


class EventHandler(pyinotify.ProcessEvent):
    """
    Event handle the listens for the inotify events and informs all callbacks
    that are registered in the profile_listeners variable
    """
    @staticmethod
    def _get_profile_ids(event):
        path = os.path.basename(event.pathname)
        device_uid = os.path.basename(os.path.dirname(event.pathname))
        if path.endswith(".macros") and not path.startswith("."):
            id_no = path.split(".")[0]
            return id_no, device_uid
Example #6
0
def mkdir_p(path):
    g15os.mkdir_p(path)