Skip to content

Commit

Permalink
X-getdata: fix regex matching (for real)
Browse files Browse the repository at this point in the history
  • Loading branch information
fmarotta committed Mar 25, 2019
1 parent ba1f0e9 commit e0f461f
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions bioinfoconda/local/src/X-getdata.pl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

# TODO: check if new dest is overriding something.

# TODO: add --info=progress2 to rsync

# TODO: pass @ARGV as @params for rsync, e.g. to specify port or
# something else in the command line.

Expand Down Expand Up @@ -183,6 +185,10 @@
@output = rsync_simple($v_source, $data_root . $dest);
}
}
else
{
die("ERROR: unrecognised source. Please specify the protocol or the username\@host.\n");
}

# Add an entry to the index file
if (@output)
Expand All @@ -191,6 +197,7 @@
update_index(\@output);
}

print "Done.";
exit 0;

# Subroutines
Expand Down Expand Up @@ -410,11 +417,12 @@ sub find_dest_host
{
if ($dirs[$i] =~ m/[\*\?\[\]\{\}]/)
{
$localdirs .= '';
$localdirs .= '/';
last;
}
else
{
$localdirs .= $dirs[$i] . '/';
$localdirs .= '/' . $dirs[$i];
}
}

Expand Down Expand Up @@ -497,13 +505,13 @@ sub wget_simple
{
print $line;
# extract the information to be logged
if ($line =~ m/ saved \[\d+\/\d+\]/)
if ($line =~ m/ saved \[.*\]/)
{
# We want @output to contain: date,
# hour, url, path. But wget simple
# returns only date, hour, path, so we
# add the url.
@output = ($line =~ m/(.*) (.*) \(.*\) - '(.*)' saved \[\d+\/\d+\]/);
@output = ($line =~ m/(.*) (.*) \(.*\) - '(.*)' saved \[.*\]/);
splice(@output, 2, 0, $url);
}
}
Expand All @@ -516,7 +524,8 @@ sub wget_recursive
{
my $url = $_[0];
my $dest = $_[1];
my $dirname = dirname($dest);
# my $dirname = dirname($dest);
my $dirname = $dest;
my @output = ();
my @urldirs = split("/", $url);
my $cutdirs;
Expand All @@ -526,7 +535,7 @@ sub wget_recursive
die("ERROR: cannot make path $dirname.\n");
}

$cutdirs = $#urldirs-2;
$cutdirs = $#urldirs-2;
# we subtract the false dirs generated by ://
open(WGETOUTPUT, "wget -P $dirname \\
-N --no-verbose --show-progress \\
Expand All @@ -536,7 +545,7 @@ sub wget_recursive
while (my $line = <WGETOUTPUT>)
{
# update the progress line...
if ($line =~ m/^\s+\d/ and $line =~ m/%/)
if ($line =~ m/^\s*\d/ and $line =~ m/%/)
{
chomp $line;
print "\r$line";
Expand Down

0 comments on commit e0f461f

Please sign in to comment.