Author: jsuchome Date: Tue Jul 1 16:09:39 2008 New Revision: 48725 URL: http://svn.opensuse.org/viewcvs/yast?rev=48725&view=rev Log: read the time using ag_time, added hctosys sync to ag_time Modified: branches/tmp/lslezak/workshop/country/timezone/agents/ag_time branches/tmp/lslezak/workshop/country/timezone/src/Timezone.ycp Modified: 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=48725&r1=48724&r2=48725&view=diff ============================================================================== --- branches/tmp/lslezak/workshop/country/timezone/agents/ag_time (original) +++ branches/tmp/lslezak/workshop/country/timezone/agents/ag_time Tue Jul 1 16:09:39 2008 @@ -16,12 +16,24 @@ if ($command eq "Read") { if ($path eq '.') { + my $format = "+%H:%M:%S - %Y-%m-%d"; + my $argmap = (); + $argmap = $argument if + (defined $argument && ref ($argument) eq "HASH"); + $format = "+%c" if $argmap->{"localized"}; + $format = $argmap->{"format"} if defined $argmap->{"format"}; - 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); + my $cmd = "/bin/date \"$format\""; + if ($argmap->{"timezone"}) { + $cmd = "TZ=".$argmap->{"timezone"}." $cmd"; + } + if ($argmap->{"datestring"}) { + $cmd = $cmd." ".$argmap->{"datestring"}; + } + y2debug ("cmd to call: '$cmd'"); + my $time = `$cmd 2>&1`; + chop $time; + ycp::Return ($time); } else { y2error ("wrong path ($path) or argument: ", ref ($argument)); @@ -69,7 +81,7 @@ } } } - elsif ($path eq '.sys2hw') { + elsif ($path eq '.systohc') { if (!defined $argument) { y2error ("argument is missing"); @@ -100,6 +112,33 @@ } } } + elsif ($path eq '.hctosys') { + + 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->{"hwclock"}) { + y2error ("hwclock key is missing"); + ycp::Return("false"); + } + else { + my $hwclock = $argument->{"hwclock"}; + my $cmd = "/sbin/hwclock --hctosys $hwclock"; + my $out = `LANG=C $cmd 2>&1`; + if ($out) { + y2error ("cmd ($cmd) returned: $out"); + ycp::Return("false"); + } + else { + ycp::Return("true"); + } + } + } else { y2error ("wrong path ($path) or argument type: ", ref ($argument)); ycp::Return("false"); Modified: branches/tmp/lslezak/workshop/country/timezone/src/Timezone.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/workshop/country/timezone/src/Timezone.ycp?rev=48725&r1=48724&r2=48725&view=diff ============================================================================== --- branches/tmp/lslezak/workshop/country/timezone/src/Timezone.ycp (original) +++ branches/tmp/lslezak/workshop/country/timezone/src/Timezone.ycp Tue Jul 1 16:09:39 2008 @@ -245,17 +245,14 @@ string cmd = "/usr/sbin/zic -l " + timezone; y2milestone( "Set cmd %1", cmd ); y2milestone( "Set ret %1", SCR::Execute( .target.bash_output, cmd )); + // TODO something like + // DBUS::Execute (org.opensuse.yast/timezone.set, timezone) if (!Arch::s390 ()) { - cmd = "/sbin/hwclock --hctosys " + hwclock; - y2milestone( "Set cmd %1", cmd ); - y2milestone( "Set ret %1", SCR::Execute(.target.bash_output, cmd )); + SCR::Write (.time.hctosys, $[ "hwclock" : hwclock ]); } if (inst && !textmode) SCR::Execute ( .target.bash, "/usr/bin/xset +dpms"); - - // TODO something like - // DBUS::Execute (org.opensuse.yast/timezone.set, timezone) } // On first assignment store default timezone. @@ -371,7 +368,6 @@ SCR::Execute(.target.bash, cmd ); */ SCR::Write (.time, $[ - // FIXME "datestring" : sformat (" --date=\"%1/%2/%3 %4:%5:%6\"", month, day, year, hour, minute, second), "hwclock" : hwclock, @@ -397,7 +393,7 @@ y2milestone ("cmd %1", cmd); SCR::Execute(.target.bash, cmd); */ - SCR::Write (.time.sys2hw, $[ + SCR::Write (.time.systohc, $[ "hwclock" : hwclock, "timezone" : timezone ]); @@ -502,20 +498,18 @@ */ global define string GetDateTime (boolean real_time, boolean locale_format) { - string cmd = ""; - - string date_format = (locale_format && Mode::normal ()) - ? "+%c" : "+%H:%M:%S - %Y-%m-%d"; + y2milestone( "GetDateTime hwclock %1 real:%2, locale %3", + hwclock, real_time, locale_format); - y2milestone( "GetDateTime hwclock %1 real:%2", hwclock, real_time ); + map argmap = $[ + "localized" : locale_format + ]; if (!real_time && !Mode::config ()) { integer ds = 0; if (diff!=0) { - map out = (map) SCR::Execute (.target.bash_output, "date +%z"); - string tzd = out["stdout"]:""; - y2milestone( "GetDateTime tcd=%1", tzd ); + string tzd = (string) SCR::Read (.time, $[ "format" : "+%z" ]); integer t = tointeger( String::CutZeros( substring( tzd, 1, 2 ))); if (t != nil) { @@ -527,32 +521,14 @@ y2milestone( "GetDateTime ds %1 diff %2", ds, diff ); } } - cmd = ""; if (hwclock != "--localtime") - { - cmd = sformat( "TZ=%1 ", timezone ); - } - cmd = cmd + sformat( "/bin/date \"%1\" \"--date=now %2sec\"", - date_format, ds*diff ); - } - else { - cmd = sformat( "/bin/date \"%1\"", date_format ); - // use new agent only here for now.... FIXME - map argmap = $[ - "localized" : locale_format - ]; - string local_date = (string) SCR::Read (.time, argmap); - y2internal (".time agent returned %1", local_date); - return local_date; - } - y2milestone( "GetDateTime cmd=%1", cmd ); - map out = (map) SCR::Execute (.target.bash_output, cmd); - string local_date = out["stdout"]:""; - - y2milestone( "GetDateTime local_date=%1", local_date ); - - return( local_date ); + argmap["timezone"] = timezone; + argmap["datestring"] = sformat ("\"--date=now %1sec\"", ds*diff); } + string local_date = (string) SCR::Read (.time, argmap); + y2milestone (".time agent returned %1", local_date); + return local_date; +} /** * Clear the internal map with timezones, so the timezone data could be -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org