Author: jsuchome Date: Tue Jul 1 11:27:20 2008 New Revision: 48700 URL: http://svn.opensuse.org/viewcvs/yast?rev=48700&view=rev Log: new agent exactly for reading/writing time (using the nice path) Added: branches/tmp/lslezak/workshop/country/timezone/agents/ag_time (with props) branches/tmp/lslezak/workshop/country/timezone/agents/time.scr Modified: branches/tmp/lslezak/workshop/country/timezone/agents/Makefile.am Modified: branches/tmp/lslezak/workshop/country/timezone/agents/Makefile.am URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/workshop/country/timezone/agents/Makefile.am?rev=48700&r1=48699&r2=48700&view=diff ============================================================================== --- branches/tmp/lslezak/workshop/country/timezone/agents/Makefile.am (original) +++ branches/tmp/lslezak/workshop/country/timezone/agents/Makefile.am Tue Jul 1 11:27:20 2008 @@ -2,4 +2,7 @@ # Makefile.am for country/timezone/agents # scrconf_DATA = $(patsubst $(srcdir)/%,%,$(wildcard $(srcdir)/*.scr)) + +agent_SCRIPTS = ag_time + EXTRA_DIST = $(scrconf_DATA) Added: branches/tmp/lslezak/workshop/country/timezone/agents/ag_time URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/workshop/country/timezone/agents/ag_time?rev=48700&view=auto ============================================================================== --- branches/tmp/lslezak/workshop/country/timezone/agents/ag_time (added) +++ branches/tmp/lslezak/workshop/country/timezone/agents/ag_time Tue Jul 1 11:27:20 2008 @@ -0,0 +1,86 @@ +#!/usr/bin/perl -w + +use lib "/usr/lib/YaST2/agents_non_y2"; +use ycp; +use strict; + + +# --------------------------------------- main ----------------------------- +while ( <STDIN> ) +{ + + my ($command, $path, $argument) = ycp::ParseCommand ($_); + + y2debug ("command: $command, path: $path"); + + if ($command eq "Read") { + + if ($path eq '.') { + + my $format = "+%H:%M:%S - %Y-%m-%d"; + $format = "+%c" if (defined $argument && ref ($argument) eq "HASH" && $argument->{"localized"}); + my $time = `/bin/date \"$format\"`; + chop $time; + ycp::Return ($time); + } + else { + y2error ("wrong path ($path) or argument: ", ref ($argument)); + ycp::Return("false"); + } + } + elsif ( $command eq "Write" ) + { + if ($path eq '.') { + if (!defined $argument) { + y2error ("argument is missing"); + ycp::Return("false"); + } + elsif (ref ($argument) ne "HASH") { + y2error ("argument must be a hash"); + ycp::Return("false"); + } + elsif (!$argument->{"datestring"} || !$argument->{"hwclock"}) { + y2error ("wrong arguments"); + ycp::Return("false"); + } + else { + my $datestring = $argument->{"datestring"}; + my $hwclock = $argument->{"hwclock"}; + my $timezone = $argument->{"timezone"}; + my $cmd = "/sbin/hwclock --set $hwclock $datestring"; + if ($hwclock eq "--utc" && $timezone) { + $cmd = "TZ=$timezone ".$cmd; + } +y2internal ("cmd: $cmd"); + my $out = `LANG=C $cmd 2>&1`; + if ($out) { + y2error ("cmd returned: $out"); + ycp::Return("false"); + } + else { +# TODO cmd = "/sbin/hwclock --hctosys $hwlock" + ycp::Return("true"); + } + } + } + elsif ($path eq '.sys2hw') { + y2error ("path $path not implemented yet"); + ycp::Return("false"); + } + else { + y2error ("wrong path ($path) or argument type: ", ref ($argument)); + ycp::Return("false"); + } + } + elsif ( $command eq "result") + { + exit; + } + else + { + y2error ("wrong command: $command"); + ycp::Return("wrong command ($command)"); + } +} + +# end Added: branches/tmp/lslezak/workshop/country/timezone/agents/time.scr URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/workshop/country/timezone/agents/time.scr?rev=48700&view=auto ============================================================================== --- branches/tmp/lslezak/workshop/country/timezone/agents/time.scr (added) +++ branches/tmp/lslezak/workshop/country/timezone/agents/time.scr Tue Jul 1 11:27:20 2008 @@ -0,0 +1,6 @@ +/** + * File: + */ +.time + +`ag_time () -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org