Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Lock/Hold on a file
Lax
Hi,
From Perl code, how can I determine whether there is a lock/hold on a particular file? Is there an extended attribute that holds this info?
Thanks,
Find more posts tagged with
Comments
Johnny
I believe the command line tool
iwlockinfo
is what you are looking for.
there are probably a few other methods too.
John Cuiuli
megamala
I think you can find out using iwlock CLT.
MM Guptha
Jeremy
iwlistlocks.exe
Lists the locks and assignments in a workarea or branch. Displays the following information:
lock date, file path, workarea, state, creator/assigner, owner/assignee, comments. To see if a file
is locked, see the istagged attribute of iwattrib (page 88).
Have a look at the CLT doc. Search for Lock - comes up as one of the first choices.
You could write a script to then check through the results of this to see if your file is there. There might be an easier method though. Someone else can pipe up.
Johnny
told you there were a few others
John Cuiuli
Jeremy
Seems we all replied at the same time!
But I think your option was probably the best, Johhny, as you can specify the file without having to search for it.
Lax
Thank you to all of you who replied.
I guess I need a little more help here. Let me explain what I'm trying to do.
The attached file is used to do delayed deploys. It sweeps through all workareas to find all files for which a date has been entered in the 'Deploy Date' in the metadata. If the date is today's date or before, then the file is pushed into Staging.
So while this happens, it first looks at files that have a HOLd on it and then it will find out if there is deploy date on it.
This is some old code that was written long before my time. It had been working at one point, but doesn't work now. The first if loop (inside the function test_mod) checks to see if the file has an extended attibute set for 'TeamSite/DeferredDeploy/HOLD'.
Is this extended attribute a customized one or is it a standard one. I don't know where or when this is being set.
If anyone could throw some light on it, it will be greatly appreciated.
Please let me know if you need more information from me.
Lax
Couldn't attach the file :
Here is the code :
#!D:\PROGRA~1\INTERW~1\TeamSite/iw-perl/bin/iwperl
# this script walks through all the work areas
# in a branch and looks for files that have
# had their placement in staging deferred.
# if it is time to be placed in staging, the
# files are then submitted to staging.
my $debug_output;
$debug_output = "e:\\iw-logs\\dddebug.log";
my $curtime = localtime;
debug("==================== $curtime");
debug("Sweeper called with p1=$ARGV[0] ");
#######################################################
### parameters:
### 1 - branch to sweep
### 2+ - any additional names to email results to
my $branch = $ARGV[0];
##$branch = "\\default\\main\\Intranet\\Wellnet";
use TeamSite::Config;
my $iwhome = TeamSite::Config::iwgethome();
#######################################################
### SETTINGS
my $ddate_attr_name = "TeamSite/Metadata/Deploy date";
my $hold_attr_name = "TeamSite/DeferredDeploy/HOLD";
my $sendto_list;
$sendto_list = [
'KarnakarLG@wellmark.com',
];
my $report_body;
my $mailserver = 'dsmntexch01.int.wellmark.com';
my $fromval = 'deferred_deploy@dsmntcms1.int.wellmark.com';
#######################################################
### DEBUG SETTINGS
#$mailserver = '148.94.34.200';
#$sendto_list = [
# 'david.ratliff@eds.com',
# ];
#######################################################
### DETERMINE CUTOFF DATE
### if deploy date is after this date, hold the file
my $curtime = localtime;
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
my $cutoff_date = "2002-02-15";
$cutoff_date = sprintf("%04i-%02i-%02i", $year + 1900, $mon + 1, $mday);
# pretend one month in future for testing
#$cutoff_date = sprintf("%04i-%02i-%02i", $year + 1900, $mon + 2, $mday);
#######################################################
### LOOP OVER WORK AREA
foreach $warea ( `$iwhome\\bin\\iwlist Y:$branch\\WORKAREA `) {
chomp $warea;
sweep_area( $branch,$warea );
}
#######################################################
### REPORT ON RESULTS
if ($report_body) {
## print $report_body;
############
## add command line args to sendto list
shift(
@ARGV)
;
push
@$sendto_list
,
@ARGV
;
use Mail::Mailer;
my $mailer = new Mail::Mailer('smtp', Server => $mailserver);
my(%headers) = ('To' => $sendto_list,
'From' => $fromval,
'Subject' => 'Deferred Deploy Report'
);
$mailer->open(\%headers);
print $mailer $report_body;
$mailer->close;
}
#######################################################
#######################################################
# sweep_area subrouting
#
# sweep through a work area and look for files to
# put into staging. use iwlistmod.exe to only
# look at modified files to speed processing.
sub sweep_area
{
my $br_name = shift(
@_)
;
my $wa_name = shift(
@_)
;
my
@submit_list
= ( );
debug("Sweeping work area ($wa_name) in branch ($br_name)");
foreach $modification ( `$iwhome\\bin\\iwlistmod $br_name\\WORKAREA\\$wa_name ` ) {
if ($modification =~ /^\+\s+(.+)$/) {
#debug(" inside if modification ");
my $modf = $1;
if ( test_mod( "$br_name\\WORKAREA\\$wa_name\\$modf" )) {
debug(" inside if test_mod");
push
@submit_list
, $modf;
}
}
}
debug(" after for each");
if (
@submit_list
) {
debug ("Need To Submit");
report ("\n\n====================\n");
report ("The following files in the work area $wa_name\nare being submitted to the staging area.\n");
##################################
# create filelist and clear approval flag
my $flist_fname = 'E:\iw-logs\filelist\sweeper_list.txt';
open(FLIST, "> $flist_fname");
foreach $fyle (
@submit_list
) {
debug( "ADDING $fyle TO SUBMIT LIST" );
report( " $fyle\n" );
my $full_fyle = "Y:\\$br_name\\WORKAREA\\$wa_name\\$fyle";
my $dd_owner = `$iwhome\\bin\\iwextattr -g $hold_attr_name "$full_fyle" 2> NUL `;
print FLIST "$curtime\n";
print FLIST "$full_fyle\n";
print FLIST "Deferred Deploy Submit approved by $dd_owner";
`$iwhome\\bin\\iwextattr -d $hold_attr_name "$full_fyle" 2> NUL `;
}
close FLIST;
##################################
# Submit the files
my $r = `$iwhome\\bin\\iwsubmit -u -r -c Deferred_Deploy -f $flist_fname `;
##################################
# Report on the submit results
report ( "--------------------\n");
report ( "The results of the iwsubmit are\n");
report ( "--------------------\n");
report ( "$r\n");
report ( "====================\n");
}
}
#######################################################
#######################################################
# test_mod subroutine
#
# test a modification to see if it is ready to be deployed
sub test_mod
{
my $modf = shift(
@_)
;
#debug("TESTING $modf");
##################################
# See if file has a hold on it.
my $dd_owner = `$iwhome\\bin\\iwextattr -g $hold_attr_name "Y:\\$modf" 2> NUL `;
chomp $dd_owner;
if ( $dd_owner ne "" ) {
debug("FOUND HOLD BY $dd_owner ON $modf");
##################################
# File has a hold on it
# See if it is time to deploy
my $dd_date = `$iwhome\\bin\\iwextattr -g "$ddate_attr_name" "Y:\\$modf" 2> NUL `;
if ($dd_date =~ m#(\d\d)/(\d\d)/(\d\d\d\d)#) {
debug("FILE READY TO BE DEPLOYED ($dd_date)");
my $deploy_date = "$3-$1-$2";
if ($deploy_date le $cutoff_date) {
debug("FILE READY TO BE DEPLOYED ($dd_date)");
##################################
# It is time to deploy.
return 1;
}
}
}
return 0;
}
#######################################################
#######################################################
sub debug
{
if ($debug_output)
{
#print STDERR
@_
; print STDERR "\n";
# Just return if it fails to open debug file
open (OUT, ">>$debug_output") || return;
print OUT
@_
; print OUT "\n";
close OUT;
}
}
sub report
{
if ($sendto_list)
{
$report_body .= shift(
@_)
;
}
}
JonathonG
I'm fairly certain that that is a custom extended attribute. I don't know of any of the IW products that set that kind of attribute.
Jonathon
Independent Interwoven Contractor
SecureChannel.JPG
Amazon_TCPIP.JPG