Bug 266179

Summary: Wrong usage of .target.bash_output from UsersPlugins.pm
Product: [openSUSE] openSUSE 10.3 Reporter: Lukas Ocilka <locilka>
Component: YaST2Assignee: Jiří Suchomel <jsuchome>
Status: RESOLVED FIXED QA Contact: Jiri Srain <jsrain>
Severity: Normal    
Priority: P5 - None    
Version: Alpha 3   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: Other Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Comment 2 Lukas Ocilka 2007-04-19 13:45:55 UTC
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");
Comment 3 Jiří Suchomel 2007-04-19 13:51:39 UTC
Please stop wasting your time. For accessing the system, we are using SCR.
Comment 4 Lukas Ocilka 2007-04-19 14:03:58 UTC
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.
Comment 5 Jiří Suchomel 2007-08-17 08:55:27 UTC
yast2-users-2.15.36