[Uludag-commits] r16964 - branches/mudur/bin
uludag-commits at pardus.org.tr
uludag-commits at pardus.org.tr
4 Şub 2008 Pzt 16:39:20 EET
Author: bahadir.kandemir
Date: Mon Feb 4 16:39:20 2008
New Revision: 16964
Modified:
branches/mudur/bin/muavin.py
branches/mudur/bin/mudur.py
branches/mudur/bin/network.py
branches/mudur/bin/service.py
branches/mudur/bin/service2.py
branches/mudur/bin/update-environment.py
Log:
merge with trunk
Modified: branches/mudur/bin/muavin.py
=================================================================
--- branches/mudur/bin/muavin.py (original)
+++ branches/mudur/bin/muavin.py Mon Feb 4 16:39:20 2008
@@ -27,7 +27,7 @@
path = os.path.join(root, "modalias")
aliases.append(file(path).read().rstrip("\n"))
return aliases
-
+
def _match(self, match, alias, mod):
# bu garip fonksiyon pythonun re ve fnmatch modullerinin
# acayip yavas olmasindan turedi, 5 sn yerine 0.5 saniyede
@@ -52,7 +52,7 @@
if j == -1:
return False
alias = alias[j:]
-
+
def aliasModules(self, aliases):
modules = set()
if len(aliases) == 0:
@@ -71,7 +71,7 @@
if self._match(a, alias, mod):
modules.add(mod)
return modules
-
+
def plug(self, current, env=None):
aliases = []
if env:
@@ -83,7 +83,7 @@
aliases = self.coldAliases()
mods = self.aliasModules(aliases)
current.update(mods)
-
+
def debug(self):
aliases = self.coldAliases()
mods = self.aliasModules(aliases)
@@ -102,14 +102,14 @@
if id == "PNP0400" or id == "PNP0401":
return [ "parport_pc", "lp" ]
return []
-
+
def plug(self, current, env=None):
if env:
# ISA bus doesn't support hotplugging
return
-
+
current.update(self.detect())
-
+
def debug(self):
print "ISAPNP: %s" % ", ".join(self.detect())
@@ -123,7 +123,7 @@
"5": ["sr_mod"],
"7": ["sd_mod"],
}
-
+
def detect(self, devpath):
path = "/sys" + devpath + "/type"
# If type information is not ready, wait a bit
@@ -131,17 +131,17 @@
while timeout > 0 and not os.path.exists(path):
time.sleep(0.1)
timeout -= 0.1
-
+
type = file(path).read().rstrip("\n")
return self.modmap.get(type, None)
-
+
def plug(self, current, env=None):
if not env or env.get("ACTION", "") != "add" or env.get("SUBSYSTEM", "") != "scsi":
return
mods = self.detect(env["DEVPATH"])
if mods:
current.update(mods)
-
+
def debug(self):
pass
@@ -156,7 +156,7 @@
loading = devpath + "/loading"
if not os.path.exists(loading):
time.sleep(1)
-
+
f = file(loading, "w")
if not os.path.exists(firm):
f.write("-1\n")
@@ -169,7 +169,7 @@
f = file(loading, "w")
f.write("0\n")
f.close()
-
+
def debug(self):
pass
@@ -200,7 +200,7 @@
self.name = line.split(":")[1].strip()
elif line.startswith("flags"):
self.flags = line.split(":", 1)[1].strip().split()
-
+
def _find_pci(self, vendor, device):
path = "/sys/bus/pci/devices"
for item in os.listdir(path):
@@ -209,7 +209,7 @@
if ven == vendor and dev == device:
return item
return None
-
+
def _detect_ich(self):
ich = 0
if self._find_pci("0x8086", "0x24cc"):
@@ -224,7 +224,7 @@
if not self._find_pci("0x8086", "0x"):
ich = 2
return ich
-
+
def _detect_acpi_pps(self):
# NOTE: This may not be a correct way to detect this
if os.path.exists("/proc/acpi/processor/CPU0/info"):
@@ -233,7 +233,7 @@
if line.split(":")[1].strip() == "yes":
return True
return False
-
+
def detect(self):
modules = set()
if self.vendor == "GenuineIntel":
@@ -256,7 +256,7 @@
# harm than good
#elif "acpi" in self.flags and "tm" in self.flags:
# modules.add("p4-clockmod")
-
+
elif self.vendor == "AuthenticAMD":
# Mobile K6-1/2 CPUs
if self.family == 5 and (self.model == 12 or self.model == 13):
@@ -267,20 +267,20 @@
# AMD Opteron/Athlon64
elif self.family == 15:
modules.add("powernow_k8")
-
+
elif self.vendor == "CentaurHauls":
# VIA Cyrix III Longhaul
if self.family == 6:
if self.model >= 6 and self.model <= 9:
modules.add("longhaul")
-
+
elif self.vendor == "GenuineTMx86":
# Transmeta LongRun
if "longrun" in self.flags:
modules.add("longrun")
-
+
return modules
-
+
def plug(self, current, env=None):
if env:
return
@@ -294,7 +294,7 @@
mods.add("cpufreq_powersave")
mods.add("cpufreq_ondemand")
current.update(mods)
-
+
def debug(self):
print "CPU: %s" % ", ".join(self.detect())
@@ -305,7 +305,7 @@
# This card is detected over bttv module's api
# If we have a bttv hardware, give the module a chance
current.add("dvb_bt8xx")
-
+
def debug(self):
pass
@@ -354,10 +354,10 @@
if __name__ == "__main__":
if len(sys.argv) == 2 and sys.argv[1] == "--debug":
debug()
-
+
elif len(sys.argv) == 2 and sys.argv[1] == "--coldplug":
plug()
-
+
else:
# This file is written by mudur, after loading of modules in the
# modules.autoload.d finishes, thus preventing udevtrigger events
Modified: branches/mudur/bin/mudur.py
=================================================================
Suppressed!
Too long (more than 250 lines) diff output suppressed...
Modified: branches/mudur/bin/network.py
=================================================================
Suppressed!
Too long (more than 250 lines) diff output suppressed...
Modified: branches/mudur/bin/service.py
=================================================================
--- branches/mudur/bin/service.py (original)
+++ branches/mudur/bin/service.py Mon Feb 4 16:39:20 2008
@@ -59,7 +59,7 @@
"script": _("script"),
"server": _("server"),
}
-
+
def __init__(self, name, info=None):
self.name = name
self.running = ""
@@ -93,12 +93,12 @@
run_title = _("Status")
auto_title = _("Autostart")
desc_title = _("Description")
-
+
name_size = max(max(map(lambda x: len(x.name), services)), len(name_title))
run_size = max(max(map(lambda x: len(x.running), services)), len(run_title))
auto_size = max(max(map(lambda x: len(x.autostart), services)), len(auto_title))
desc_size = len(desc_title)
-
+
line = "%s | %s | %s | %s" % (
name_title.center(name_size),
run_title.center(run_size),
@@ -107,7 +107,7 @@
)
print line
print "-" * (len(line))
-
+
cstart = ""
cend = ""
if use_color:
@@ -134,14 +134,14 @@
data = collect(c)
services = filter(lambda x: x.command == "result", data)
errors = filter(lambda x: x.command != "result", data)
-
+
if len(services) > 0:
services.sort(key=lambda x: x.script)
lala = []
for item in services:
lala.append(Service(item.script, item.data))
format_service_list(lala, use_color)
-
+
if len(errors) > 0:
print
map(report_error, errors)
@@ -163,27 +163,27 @@
sys.exit(3)
print _("Comar service is running.")
sys.exit(0)
-
+
if os.getuid() != 0:
print _("You should be the root user in order to control the comar service.")
sys.exit(1)
-
+
comar_pid = "/var/run/comar.pid"
-
+
if op == "stop" or op == "restart":
os.system("/sbin/start-stop-daemon --stop --pidfile %s" % comar_pid)
-
+
timeout = 5
while checkDaemon(comar_pid) and timeout > 0:
time.sleep(0.2)
timeout -= 0.2
-
+
if op == "start" or op == "restart":
os.system("/sbin/start-stop-daemon -b --start --pidfile %s --make-pidfile --exec /usr/bin/comar" % comar_pid)
def manage_service(service, op, use_color=True):
c = comlink()
-
+
if op == "start":
c.ask_notify("System.Service.changed")
c.System.Service[service].start()
@@ -202,7 +202,7 @@
manage_service(service, "stop")
manage_service(service, "start")
return
-
+
while True:
reply = c.read_cmd()
if reply.command == "result":
@@ -218,7 +218,7 @@
if op == "status":
sys.exit(4)
sys.exit(1)
-
+
if op in ["info", "status", "list"]:
s = Service(reply.script, reply.data)
format_service_list([s], use_color)
@@ -257,7 +257,7 @@
def main(args):
operations = ("start", "stop", "info", "list", "restart", "reload", "status", "on", "off")
use_color = True
-
+
# Parameters
if "--no-color" in args:
args.remove("--no-color")
@@ -265,26 +265,26 @@
if "-N" in args:
args.remove("-N")
use_color = False
-
+
# Operations
if args == []:
list_services(use_color)
-
+
elif args[0] == "list" and len(args) == 1:
list_services(use_color)
-
+
elif args[0] == "help":
usage()
-
+
elif len(args) < 2:
usage()
-
+
elif args[0] == "comar":
manage_comar(args[1])
-
+
elif args[1] in operations:
manage_service(args[0], args[1], use_color)
-
+
else:
usage()
Modified: branches/mudur/bin/service2.py
=================================================================
--- branches/mudur/bin/service2.py (original)
+++ branches/mudur/bin/service2.py Mon Feb 4 16:39:20 2008
@@ -113,17 +113,17 @@
print line
def startService(service, bus):
- obj = bus.get_object("tr.org.pardus.comar", "/package/%s" % service)
+ obj = bus.get_object("tr.org.pardus.comar", "/package/%s" % service, introspect=False)
print _("Starting %s..." % service)
obj.start(dbus_interface="tr.org.pardus.comar.System.Service")
def stopService(service, bus):
- obj = bus.get_object("tr.org.pardus.comar", "/package/%s" % service)
+ obj = bus.get_object("tr.org.pardus.comar", "/package/%s" % service, introspect=False)
print _("Stopping %s..." % service)
obj.stop(dbus_interface="tr.org.pardus.comar.System.Service")
def setServiceState(service, state, bus):
- obj = bus.get_object("tr.org.pardus.comar", "/package/%s" % service)
+ obj = bus.get_object("tr.org.pardus.comar", "/package/%s" % service, introspect=False)
obj.setState(state, dbus_interface="tr.org.pardus.comar.System.Service")
if state == "on":
print _("Service '%s' will be auto started.") % service
@@ -131,16 +131,16 @@
print _("Service '%s' won't be auto started.") % service
def reloadService(service, bus):
- obj = bus.get_object("tr.org.pardus.comar", "/package/%s" % service)
+ obj = bus.get_object("tr.org.pardus.comar", "/package/%s" % service, introspect=False)
print _("Reloading %s..." % service)
obj.reload(dbus_interface="tr.org.pardus.comar.System.Service")
def getServiceInfo(service, bus):
- obj = bus.get_object("tr.org.pardus.comar", "/package/%s" % service)
+ obj = bus.get_object("tr.org.pardus.comar", "/package/%s" % service, introspect=False)
return obj.info(dbus_interface="tr.org.pardus.comar.System.Service")
def getServices(bus):
- obj = bus.get_object("tr.org.pardus.comar", "/")
+ obj = bus.get_object("tr.org.pardus.comar", "/", introspect=False)
return obj.listModelApplications("System.Service", dbus_interface="tr.org.pardus.comar")
def list_services(use_color=True):
Modified: branches/mudur/bin/update-environment.py
=================================================================
--- branches/mudur/bin/update-environment.py (original)
+++ branches/mudur/bin/update-environment.py Mon Feb 4 16:39:20 2008
@@ -48,7 +48,7 @@
def read_env_d(envdir):
dict = {}
-
+
paths = []
for name in os.listdir(envdir):
path = os.path.join(envdir, name)
@@ -64,12 +64,12 @@
continue
paths.append(path)
paths.sort()
-
+
for path in paths:
for line in file(path):
if line == "" or line.startswith("#"):
continue
-
+
line = line.rstrip("\n")
if "=" in line:
key, value = line.split("=", 1)
@@ -77,7 +77,7 @@
value = value.strip()
if value.startswith('"') or value.startswith("'"):
value = value[1:-1]
-
+
# Merge for special variables, override for others
if key in specials:
if dict.has_key(key):
@@ -86,7 +86,7 @@
dict[key] = value.split(":")
else:
dict[key] = value
-
+
return dict
def generate_profile_env(envdict, format='export %s="%s"\n'):
@@ -113,7 +113,7 @@
def update_environment(prefix):
join = os.path.join
-
+
env = read_env_d(join(prefix, "etc/env.d"))
update_file(join(prefix, "etc/profile.env"), generate_profile_env(env))
update_file(join(prefix, "etc/csh.env"), generate_profile_env(env, 'setenv %s %s\n'))
@@ -130,19 +130,19 @@
def main(argv):
prefix = "/"
-
+
try:
opts, args = getopt.gnu_getopt(argv, "h", [ "help", "destdir=" ])
except getopt.GetoptError:
usage()
-
+
for o, a in opts:
if o in ("-h", "--help"):
usage()
sys.exit(0)
if o in ("--destdir"):
prefix = a
-
+
update_environment(prefix)
if __name__ == "__main__":
Uludag-commits mesaj listesiyle ilgili
daha fazla bilgi