Repository navigation
Expand file tree
/
Copy pathfilecopy_tests.pl
More file actions
executable file
·114 lines (88 loc) · 2.2 KB
/
Copy pathfilecopy_tests.pl
File metadata and controls
executable file
·114 lines (88 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/perl -w
#
use strict;
use XML::Simple;
use Data::Dumper;
use Time::Piece;
use YAML;
use threads;
my $download_output = 0;
sub downloader_thread {
my $i = 0;
print "Downloader Thread\n";
while ($i < 5) {
# sleep (1);
if ($download_output) {
print "*";
}
$i++;
}
}
my $a = {
"Camera1" => { uuid => '284aca4e-6d05-451a-b2d4-58e952ea42e8', lastimport => "16/06/2015" },
"Camera2" => { uuid => '6feff0cd-d598-45e1-adcf-23522c5a5a0d', lastimport => "16/06/2015" }
};
my $xmlout = XMLout($a);
print "$xmlout";
my $b = XMLin($xmlout);
print Dumper($b);
foreach my $key (keys($b)) {
print $key . "\n";
if ($b->{$key}->{uuid} eq '6feff0cd-d598-45e1-adcf-23522c5a5a0d') {
print $b->{$key}->{lastimport} . "\n";
}
}
print "Add Camera: ";
my $cam = <STDIN>;
print "Add UUID: ";
my $uuid = <STDIN>;
chomp $uuid;
chomp $cam;
my $timedate = localtime();
$b->{$cam} = { uuid => $uuid, lastimport => $timedate->datetime, tzoffset => $timedate->tzoffset->hours };
$xmlout = XMLout($b);
print "$xmlout";
# Create a thread with a specific context and stack size
my $thr = threads->create({ 'context' => 'list',
'stack_size' => 32*4096,
'exit' => 'thread_only' },
\&downloader_thread);
print "Enter Description: \n";
my $desc;
##while (<STDIN>) {
## last if /^END$/;
## $desc .= $_;
##}
print "Desc: $desc\n";
$download_output = 1;
# Get thread's context
#my $wantarray = $thr->wantarray();
# Check thread's state
while ($thr->is_running()) {
sleep(1);
}
if ($thr->is_joinable()) {
$thr->join();
}
# Send a signal to a thread
#$thr->kill('SIGUSR1');
# Exit a thread
#threads->exit();
my $dataDownload = {
file1 => {
fname => "filename",
sum => "bdfd6cfa459da456e61c9ac7ee12caa3791a045d2432f672e965a0f9213a372d",
descfile => "descfile",
},
file2 => {
fname => "filename1",
sum => "c6657d0f4b06440abf438e5bc63323daffbfc02ae8ca50085b9e9cb9fe91964c",
descfile => "descfile",
}
};
$xmlout = XMLout($dataDownload);
print "$xmlout";
my $ymlout = Dump($dataDownload);
print $ymlout;
my $ymlin = Load($ymlout);
print Dumper($ymlin);