Page MenuHomec4science

Move_to_Done.py.wml
No OneTemporary

File Metadata

Created
Tue, Nov 5, 11:33

Move_to_Done.py.wml

## $Id$
## This file is part of the CERN Document Server Software (CDSware).
## Copyright (C) 2002 CERN.
##
## The CDSware is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
## published by the Free Software Foundation; either version 2 of the
## License, or (at your option) any later version.
##
## The CDSware is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with CDSware; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
## read config variables:
#include "config.wml"
#include "configbis.wml"
<protect>
## $Id$
## DO NOT EDIT THIS FILE! IT WAS AUTOMATICALLY GENERATED FROM CDSware WML SOURCES.
## Description: function Move_to_Done
## This function move the current working directory to the
## /done directory and compress it
## Author: T.Baron
## PARAMETERS: -
def Move_to_Done(parameters,curdir,form):
global rn
data = re.search(".*/([^/]*)/([^/]*)/[^/]*$",curdir)
dir = data.group(1)
doctype = data.group(2)
DONEDIR = "%s/done/%s/%s" % (storage,dir,doctype)
if not os.path.exists(DONEDIR):
try:
os.makedirs(DONEDIR)
except:
raise functionError("Cannot create done directory %s" % DONEDIR)
# Moves the files to the done diectory and creates an archive
rn = rn.replace("/","-")
namedir = "%s_%s" % (rn,time.strftime("%Y%m%d%H%M%S"))
FINALDIR = "%s/%s" % (DONEDIR,namedir)
os.rename(curdir,FINALDIR)
if tar != "" and gzip != "":
os.chdir(DONEDIR)
tar_txt = "%s -cf - %s > %s.tar" % (tar,namedir,namedir)
os.system(tar_txt)
zip_txt = "%s %s.tar" % (gzip,namedir)
os.system(zip_txt)
rm_txt = "rm -R %s" % namedir
os.system(rm_txt)
return ""
</protect>

Event Timeline