[Bug 266179] New: Please, do not call .target.bash_output from Perl when not neccessary
https://bugzilla.novell.com/show_bug.cgi?id=266179 Summary: Please, do not call .target.bash_output from Perl when not neccessary Product: openSUSE 10.3 Version: Alpha 3 Platform: Other OS/Version: Other Status: NEW Severity: Enhancement Priority: P5 - None Component: YaST2 AssignedTo: jsuchome@novell.com ReportedBy: locilka@novell.com QAContact: jsrain@novell.com Index: src/UsersPluginLDAPShadowAccount.pm =================================================================== --- src/UsersPluginLDAPShadowAccount.pm (revision 37577) +++ src/UsersPluginLDAPShadowAccount.pm (working copy) @@ -65,11 +65,9 @@ # provide current value for shadowlastchange attribute sub last_change_is_now { - - my %out = %{SCR->Execute (".target.bash_output", "date +%s")}; - my $seconds = $out{"stdout"} || "0"; - chomp $seconds; - return sprintf ("%u", $seconds / (60*60*24)); + # time == current time in seconds from 1.1.1970 + # 86400 == number of seconds in one day + return int (time / 86400); } # update the list of current object classes when adding plugin -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.
https://bugzilla.novell.com/show_bug.cgi?id=266179 ------- Comment #1 from locilka@novell.com 2007-04-19 07:16 MST ------- This one as well Index: Users.pm =================================================================== --- Users.pm (revision 37584) +++ Users.pm (working copy) @@ -277,10 +277,9 @@ sub LastChangeIsNow { if (Mode->test ()) { return "0";} - my %out = %{SCR->Execute (".target.bash_output", "date +%s")}; - my $seconds = $out{"stdout"} || "0"; - chomp $seconds; - return sprintf ("%u", $seconds / (60*60*24)); + # time == current time in seconds from 1.1.1970 + # 86400 == number of seconds in one day + return int (time / 86400); } -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.
https://bugzilla.novell.com/show_bug.cgi?id=266179 ------- Comment #2 from locilka@novell.com 2007-04-19 07:45 MST ------- Using opendir, readdir, closedir rather than 'find' It cheaper to use Perl built-in functions Index: UsersPlugins.pm =================================================================== --- UsersPlugins.pm (revision 37587) +++ UsersPlugins.pm (working copy) @@ -29,21 +29,18 @@ # + initialize the hash of plugin interface BEGIN { $TYPEINFO{Read} = ["function", "boolean"]; } sub Read { - - my $find = "/usr/bin/find ".Directory->moduledir(); - $find .= " -name 'UsersPlugin*.*'"; #TODO use some variable for the name - my $out = SCR->Execute (".target.bash_output", $find); - my $modules = $out->{"stdout"} || ""; - - foreach my $module (split (/\n/, $modules)) { - my @mod = split (/\//, $module); - my $m = $mod[-1] || ""; - $m =~ s/\.ycp$//g; # YCP modules cannot be called as variables... - $m =~ s/\.pm$//g; - if ($m ne "" && $m ne "UsersPlugins") { - push @available_plugins, $m; + opendir (MODULEDIR, Directory->moduledir()) || do { + y2error ("Cannot open directory '".Directory->moduledir()."'"); + return 0; + }; + my $module = ""; + foreach $module (readdir(MODULEDIR)) { + if ($module =~ s/^(UsersPlugin.+)\..+$/$1/ && + $module ne 'UsersPlugins') { + push @available_plugins, $module; } } + close (MODULEDIR); foreach my $module (@available_plugins) { y2milestone ("Available plugin: $module"); -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.
https://bugzilla.novell.com/show_bug.cgi?id=266179 jsuchome@novell.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID ------- Comment #3 from jsuchome@novell.com 2007-04-19 07:51 MST ------- Please stop wasting your time. For accessing the system, we are using SCR. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.
https://bugzilla.novell.com/show_bug.cgi?id=266179 locilka@novell.com changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|Enhancement |Normal Status|RESOLVED |REOPENED Resolution|INVALID | Summary|Please, do not call |Wrong usage of .target.bash_output from |.target.bash_output from |UsersPlugins.pm |Perl when not neccessary | ------- Comment #4 from locilka@novell.com 2007-04-19 08:03 MST ------- You are right about the initial comment and the comment #1. I was wrong, the time might be different between Library-computer and SCR-computer. On the other hand the comment #2 is valid. There is no reason why SCR should be used there. You need to have these modules accessible from the system where you run it, not from a system where you have SCR connected. If fact, it is be even a bug. You don't import the module via SCR, that's why you also can't use '.target', at least '.local' should be used. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.
https://bugzilla.novell.com/show_bug.cgi?id=266179 jsuchome@novell.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|REOPENED |ASSIGNED -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.
https://bugzilla.novell.com/show_bug.cgi?id=266179#c5
Jiří Suchomel
participants (1)
-
bugzilla_noreply@novell.com