summaryrefslogtreecommitdiff
blob: db9f6820a84d9f1184495e3ad9472fc5d1a3f3e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#! /usr/bin/env python
# A simple script to get the name and id from a Control.
# Pretty much copied from test-control.py

from plugin.Interface import Interface
from main import HOME
from plugin import Permission


import sys
import os
import code
import __builtin__

if "." not in sys.path: sys.path.append(".")
if HOME not in sys.path: sys.path.append(HOME)


try:
    path = os.path.abspath(sys.argv[1])
    folder, base = os.path.split(path)
except:
    sys.exit("Usage: gdesklets-control-getid <control-directory>")
    

cwd = os.getcwd()
os.chdir(folder)
try:
    module = __import__(base)
    os.chdir(base)
    clss = module.get_class()
    ctrl = clss()
    
except IOError:
    sys.exit("Could not load control %s." % (path))

print Interface.get_id(Interface.get_interfaces(clss)[0]).replace(":", "_")