X-Git-Url: http://dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FDXCommandmode.pm;h=975d808b115d0b022aef35e828b50f699429d2c9;hb=refs%2Fheads%2Fnewusers;hp=6306b7fbed905902abea96f23d9a14c219e98e31;hpb=63f0fc26e717837bc7c6990f27d26de91d65eb7e;p=spider.git diff --git a/perl/DXCommandmode.pm b/perl/DXCommandmode.pm index 6306b7fb..975d808b 100644 --- a/perl/DXCommandmode.pm +++ b/perl/DXCommandmode.pm @@ -13,7 +13,7 @@ package DXCommandmode; @ISA = qw(DXChannel); -require 5.10.1; +use 5.10.1; use POSIX qw(:math_h); use DXUtil; @@ -42,9 +42,10 @@ use AsyncMsg; use JSON; use Time::HiRes qw(gettimeofday tv_interval); +use Mojo::UserAgent; use Mojo::IOLoop; use Mojo::IOLoop::Subprocess; -use Mojo::UserAgent; +use DXSubprocess; use strict; use vars qw(%Cache %cmd_cache $errstr %aliases $scriptbase %nothereslug @@ -210,8 +211,7 @@ sub start $script->run($self) if $script; # send cluster info - my $info = Route::cluster(); - $self->send("Cluster:$info"); + $self->send($self->run_cmd("show/cluster")); # send prompts for qth, name and things $self->send($self->msg('namee1')) if !$user->name; @@ -545,19 +545,16 @@ sub run_cmd if ($package && $self->can("${package}::handle")) { no strict 'refs'; dbg("cmd: package $package") if isdbg('command'); - if (isdbg('progress')) { - my $s = "CMD: '$cmd' by $call ip $self->{hostname}"; - } my $t0 = [gettimeofday]; eval { @ans = &{"${package}::handle"}($self, $args) }; if ($@) { - dbgprintring(25); + DXDebug::dbgprintring(25); return (DXDebug::shortmess($@)); } if (isdbg('progress')) { my $msecs = _diffms($t0); my $s = "CMD: '$cmd $args' by $call ip: $self->{hostname} ${msecs}mS"; - dbg($s); + dbg($s) if $cmd !~ /^(?:echo|blank)/ || isdbg('echo'); # cut down a bit on HRD and other clients' noise } } else { dbg("cmd: $package not present") if isdbg('command'); @@ -839,7 +836,7 @@ sub find_cmd_name { }; #wrap the code into a subroutine inside our unique package - my $eval = qq(package DXCommandmode::$package; use POSIX qw{:math_h}; use DXLog; use DXDebug; use DXUser; use DXUtil; our \@ISA = qw{DXCommandmode}; ); + my $eval = qq(package DXCommandmode::$package; use 5.10.1; use POSIX qw{:math_h}; use DXLog; use DXDebug; use DXUser; use DXUtil; our \@ISA = qw{DXCommandmode}; ); if ($sub =~ m|\s*sub\s+handle\n|) { @@ -1320,15 +1317,15 @@ sub spawn_cmd return @out; } - my $fc = Mojo::IOLoop::Subprocess->new; + my $fc = DXSubprocess->new; # $fc->serializer(\&encode_json); # $fc->deserializer(\&decode_json); $fc->run( sub { my $subpro = shift; - if (isdbg('progress')) { - my $s = "line: $line"; - $s .= ", args: " . join(', ', @$args) if $args && @$args; + if (isdbg('spawn')) { + my $s = __PACKAGE__ . qq{ line: "$line"}; + $s .= ", args: " . join(', ', map { defined $_ ? qq{'$_'} : q{'undef'} } @$args) if $args && @$args; dbg($s); } eval { @out = $cmdref->(@$args); }; @@ -1361,7 +1358,7 @@ sub spawn_cmd $dxchan->send(@res); } } - diffms("by $call", $line, $t0, scalar @res) if isdbg('progress'); + diffms(__PACKAGE__, "by $call", $line, $t0, scalar @res) if isdbg('progress'); }); return @out;