Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F87527727
Move_Pictures_Archive.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Oct 13, 05:09
Size
3 KB
Mime Type
text/x-c
Expires
Tue, Oct 15, 05:09 (2 d)
Engine
blob
Format
Raw Data
Handle
21613648
Attached To
R3600 invenio-infoscience
Move_Pictures_Archive.py
View Options
## $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.
import
shutil
def
Move_Pictures_Archive
(
parameters
,
curdir
,
form
):
#Set local variables
if
os
.
path
.
exists
(
"
%s
/archivepath"
%
curdir
):
fp
=
open
(
"
%s
/archivepath"
%
curdir
,
"r"
)
archivepath
=
fp
.
read
()
fp
.
close
()
else
:
raise
functionError
(
"Set_Archive_Files should be called before Move_Files_Archive"
)
if
os
.
path
.
exists
(
"
%s
/formatfile"
%
curdir
):
fp
=
open
(
"
%s
/formatfile"
%
curdir
,
"r"
)
formatfile
=
fp
.
read
()
fp
.
close
()
else
:
raise
functionError
(
"Set_Archive_Files should be called before Move_Files_Archive"
)
MainDir
=
"
%s
/files/MainFiles"
%
curdir
IncludeDir
=
"
%s
/files/AdditionalFiles"
%
curdir
IconDir
=
"
%s
/files/icons"
%
curdir
# create archive directories if needed
if
not
os
.
path
.
exists
(
"
%s
/
%s
"
%
(
archivepath
,
formatfile
)):
os
.
makedirs
(
"
%s
/
%s
"
%
(
archivepath
,
formatfile
))
# create "obsolete" directory in archive in order to avoid preexisting file destruction
if
not
os
.
path
.
exists
(
"
%s
/obsolete"
%
archivepath
):
os
.
mkdir
(
"
%s
/obsolete"
%
archivepath
)
now
=
time
.
strftime
(
"%Y-%m-
%d
_%H:%M:%S"
)
# additional Files
if
os
.
path
.
exists
(
IncludeDir
):
for
root
,
dirs
,
files
in
os
.
walk
(
IncludeDir
):
for
file
in
files
:
if
os
.
path
.
exists
(
"
%s
/
%s
/
%s
"
%
(
archivepath
,
formatfile
,
file
)):
os
.
rename
(
"
%s
/
%s
/
%s
"
%
(
archivepath
,
formatfile
,
file
),
"
%s
/obsolete/
%s
_
%s
"
%
(
archivepath
,
file
,
now
))
shutil
.
copy
(
"
%s
/
%s
"
%
(
IncludeDir
,
file
),
"
%s
/
%s
/
%s
"
%
(
archivepath
,
formatfile
,
file
))
# main Files
if
os
.
path
.
exists
(
MainDir
):
for
root
,
dirs
,
files
in
os
.
walk
(
MainDir
):
for
file
in
files
:
extension
=
re
.
sub
(
"^[^\.]*\."
,
""
,
file
)
.
lower
()
if
os
.
path
.
exists
(
"
%s
/
%s
.
%s
"
%
(
archivepath
,
formatfile
,
extension
)):
os
.
rename
(
"
%s
/
%s
.
%s
"
%
(
archivepath
,
formatfile
,
extension
),
"
%s
/obsolete/
%s
.
%s
_
%s
"
%
(
archivepath
,
formatfile
,
extension
,
now
))
shutil
.
copy
(
"
%s
/
%s
"
%
(
MainDir
,
file
),
"
%s
/
%s
.
%s
"
%
(
archivepath
,
formatfile
,
extension
))
return
""
</
protect
>
Event Timeline
Log In to Comment