PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Python und Skript ^^



bluecrystal21
18-10-2010, 11:48
Hallo,
ich hab ein Skript das ein anderes Skript "terminieren" soll alle Daten des Ordners kopieren unter Linux_client speichern, überprüfen soll und dann das alles löscht und das Skript wieder startet
ich hab zwar angefangen aber beim terminieren macht es schon Probleme...
hier anbei der Code:

dp_update.py:

#!/usr/bin/env python
from __future__ import with_statement
import os,signal
import cStringIO
import os.path
import sys
import re
config_file = 'dp_clienttask.ini'
choices = (
'9', # 9: Updatet the Python-Script.
)
class Backup():
def __init__(self,config_file, choices,):
self.config_file=config_file
self.choices = choices
def read_config(self):
choice= None
try:
file = open(self.config_file)
for line in file.readlines():
if line.lower().strip().startswith("boottime"):
choice = re.split('^boottime\s*=\s*([0-9]+)[^0-9]*?$', line.lower().strip())[1]
except Exception, e:
print >> sys.stderr, '''Error: File "%s" (configuration file) couldn't be read!\nQuitting.''' % self.config_file
file.close()
def kill_script(self):
pid = os.getpid()
open('dp_backup.lock', 'w').write(str(pid))
with open('dp_backup.lock') as config:
for line in config:
os.kill(int(line), signal.SIGTERM)


def copy_script(self):
shutil.copy('dp_client.py''Linux_Client')



def run(self.config_file):
os.system('dp_client.py')


vll sieht ja einer meine Fehler
Liebe Grüße
bluecrystal21

John W
18-10-2010, 13:42
Hier geht es weiter: http://www.mrunix.de/forums/showthread.php?t=69560