Code: Alles auswählen
# imports
# -*- coding: utf-8-*-
import cStringIO
import os
import os.path
import platform
import sys
import subprocess
import re
config_file = 'dp_clienttask.ini'
file = open(config_file)
for line in file.readlines():
if line.lower().strip().startswith("boottime"):
choice = re.split('^boottime\s*=\s*([0-9]+)', line.lower().strip())[1]
elif line.lower().strip().startswith("destination="):
dest = re.split('^[dD][eE][sS][tT][iI][nN][aA][tT][iI][oO][nN]\s*=\s*(.+)\s*$', line.lower().strip())[1]
file.close()
class Lock():
if 'linux' in platform.system().lower():
# checks for lock
def check(self):
if os.path.exists(os.path.join(os.path.abspath(__file__), 'dp_backup.lock')):
try:
file = open(os.path.join(os.path.abspath(__file__), 'dp_backup.lock'))
pid = int(file.readline().strip())
file.close()
if os.path.exists('/proc/%s/' % str(pid)):
file = open('/proc/%s/cmdline' % str(pid))
line = file.readline().strip()
file.close()
if line.startswith('python'):
print >> sys.stderr, 'Warning: Process %s already running. Quitting.' % str(pid)
exit(0)
except Exception, e:
print e
elif 'windows' in platform.system().lower():
# checks for lock
def check(self):
if os.path.exists(os.path.join(os.path.abspath(__file__), 'dp_backup.lock')):
try:
file = open(os.path.join(os.path.abspath(__file__), 'dp_backup.lock'))
pid = int(file.readline().strip())
file.close()
try:
os.kill(pid, 0)
# TODO: check whether pid is a running instance of python
print >> sys.stderr, 'Warning: Process %s already running. Quitting.' % str(pid)
exit(0)
except OSError, e:
pass # process is not running
except Exception, e:
print e
class Backup():
def __init__(self, lock, config_file):
self.mac = None
file = None
if 'linux' in platform.system().lower():
try:
for i in os.listdir('/sys/class/net/'):
if self.mac != None:
break
if not i.startswith('eth'):
continue
file = open('/sys/class/net/%s/operstate' % i)
try:
if 'up' in file.read():
file.close()
file = open('/sys/class/net/%s/address' % i)
self.mac = file.readline().strip().replace(':','-')
file.close()
except:
pass
finally:
if file != None and not file.closed:
file.close()
except:
pass
if self.mac == None:
try:
for i in os.listdir('/sys/class/net/'):
if self.mac != None:
break
if not i.startswith('eth'):
continue
try:
file = open('/sys/class/net/%s/address' % i)
self.mac = file.readline().strip().replace(':','-')
file.close()
except:
pass
finally:
if file != None and not file.closed:
file.close()
except:
pass
elif 'windows' in platform.system().lower():
for line in os.popen(r"C:\WINDOWS\system32\ipconfig.exe /all"):
match = re.search('((?:[0-9A-Fa-f]{2}-){5}[0-9A-Fa-f]{2})', line)
if match != None:
self.mac = match.group()
break
if self.mac == None:
print >> sys.stderr, '''ERROR: Coulnd't retrieve MAC-address!'''
exit(1)
self.current_archive = None
file=open("file.txt","w")
file.write(dest)
file.write('\\')
file.write(self.mac)
file.close()
i=0
#while i < len(files):
# if not os.path.isfile(file[i]) or not files[i].endswith('tar.gz'):
# files.pop(i)
# i+=1
# files.sort()
# tar_file=files[-1]
# print tar_file
# previewfile = subprocess.Popen(["C:\\Programme\\7-Zip\\7zFM.exe",dest , tar_file])#, tar_file.replace('.tar.gz', '.tar')])
Need my Macadress and the path to the file-folder do you understand me?...
ich brauch dazu die mac-adresse und den Pfad zum Ordner dann die Sicherungstar und dann die gepackten Dateien.
soll ichs euch aufmalen?
~> path\mac\ordner\sicherung.tar.gz\\path\mac\ordner\sicheung.tar
das is alles was ich will.
please close my thread
es is einfach sinnlos hier zu erklären was ich erreichen möchte.