From: nick@svn.comics.unina.it
To: bismark-commits@lists.bufferbloat.net
Subject: [Bismark-commits] rev 348 - trunk/server/scripts
Date: Thu, 26 May 2011 10:22:52 +0200 [thread overview]
Message-ID: <E1QPVqF-0002eF-WF@svn.comics.unina.it> (raw)
Author: nick
Date: 2011-05-26 10:22:51 +0200 (Thu, 26 May 2011)
New Revision: 348
Modified:
trunk/server/scripts/organize-archive.py
Log:
functions for publishing files from the archive
Modified: trunk/server/scripts/organize-archive.py
===================================================================
--- trunk/server/scripts/organize-archive.py 2011-05-24 22:36:26 UTC (rev 347)
+++ trunk/server/scripts/organize-archive.py 2011-05-26 08:22:51 UTC (rev 348)
@@ -6,8 +6,9 @@
import time
import datetime
import shutil
+import tarfile
-def clean_data(dir):
+def clean_data(dir,targetdir):
UKY_DIR = os.environ['HOME'] + '/var/archive/UKY-old'
devices = []
@@ -32,6 +33,7 @@
match = re.search(r'[Uu]ky',file)
if match:
shutil.move(dir+file, UKY_DIR)
+ continue
# get list of devices
match = re.search(r'[0-9A-Za-z]+',file)
@@ -55,25 +57,54 @@
# make directories and move files
- datadir = dir+ dev_name + '/' + typedir + '/'+ datedir
+ datadir = targetdir + dev_name + '/' + typedir + '/'+ datedir
if not os.path.exists(datadir):
os.makedirs(datadir)
- #print dir+file + '->' + datadir
+ print dir+file + '->' + datadir
shutil.move(dir+file,datadir)
for dev in devices:
print dev
+
+def new_device_files(members,device,dir):
+ for tarinfo in members:
+ match = re.search(device,tarinfo.name)
+ if match:
+ yield tarinfo
-
+def unpack_backup(device,dir,outdir):
+ files = os.listdir(dir)
+ for file in files:
+ match = re.search(r'xml.tgz',file)
+ if match:
+ # unpack into the unpack dir
+ print file
+ try:
+ tar = tarfile.open(dir+file,'r:gz')
+ tar.extractall(outdir,members=new_device_files(tar,device))
+ tar.close()
+ except tarfile.ReadError:
+ print "Warning Read Error"
+
+
if __name__ == '__main__':
HOME = os.environ['HOME'] + '/'
MEASURE_FILE_DIR = 'var/data/'
+
ARCHIVE_DIR = HOME + MEASURE_FILE_DIR + 'old/'
+ BACKUP_DIR = HOME + 'var/backup/'
+ UNPACK_DIR = ARCHIVE_DIR + 'unpack/'
- clean_data(ARCHIVE_DIR)
+ PUBLISH_DIR = ARCHIVE_DIR
+
+ clean_data(ARCHIVE_DIR,PUBLISH_DIR)
+
+ # restore directory structure from backup
+ #unpack_backup('NB105',BACKUP_DIR,UNPACK_DIR)
+ #clean_data(UNPACK_DIR,PUBLISH_DIR)
reply other threads:[~2011-05-26 8:08 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1QPVqF-0002eF-WF@svn.comics.unina.it \
--to=nick@svn.comics.unina.it \
--cc=bismark-commits@lists.bufferbloat.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox