[San-Diego-pm] San-Diego-pm Digest, Vol 85, Issue 3
Reuben Settergren
ruberad at gmail.com
Wed May 11 12:21:14 PDT 2011
Thanks Bob for your help. It didn't quite work as-is, but it got me where I
needed to go.
Your BEGIN { eval{} || eval{} } construct went into the right path, but
setting the scalar variables did not work. Instead they just took advantage
of a syntax aid I didn't know about, where perl apparently helps out by
assuming you meant to put quotes around barewords (i.e. $LOW_PRIORITY eq
'BELOW_NORMAL_PRIORITY_CLASS')
What are those $-less symbols from Win32::Process anyways?
But I was able to declare a $capable scalar, and have it set to 1 or 0
depending on the success of the import, which allowed me to take appropriate
action later in the script.
AND (purists avert your eyes!) I discovered I don't even need the labels
after all. I can simply
use Win32::Process;
$below_normal = 16384;
$above_normal = 32768;
#...
$proc->SetPriorityClass($below_normal);
# OR
$proc->SetPriorityClass($above_normal);
TIMTOWDI
thanks again!
r
On Wed, May 11, 2011 at 12:00 PM, <san-diego-pm-request at pm.org> wrote:
> Send San-Diego-pm mailing list submissions to
> san-diego-pm at pm.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://mail.pm.org/mailman/listinfo/san-diego-pm
> or, via email, send a message with subject or body 'help' to
> san-diego-pm-request at pm.org
>
> You can reach the person managing the list at
> san-diego-pm-owner at pm.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of San-Diego-pm digest..."
>
>
> Today's Topics:
>
> 1. Wrangle module version? (Reuben Settergren)
> 2. Re: Wrangle module version? (Bob Kleemann)
> 3. Re: help (Joel Fentin)
> 4. Re: help (Chris Grau)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Tue, 10 May 2011 14:47:43 -0700
> From: Reuben Settergren <ruberad at gmail.com>
> To: san-diego-pm at pm.org
> Subject: [San-Diego-pm] Wrangle module version?
> Message-ID: <BANLkTinWjrYOBBsy8h9GQmAAiz-pA=TCYg at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Hello Mongers,
>
> I have what seems like it should be a simple problem (and it probably is!),
> but I'm not finding the simple solution, so I'm hoping somebody can give me
> the right answer off the top of their head.
>
> So the group I work with shares a perl script to run multi-hour builds (of
> C++, on windows boxes, with visual studio 9). Usually we try to rebuild the
> whole shebang overnight, and then work on it all day. But sometimes we have
> to build during the day, and the computer can bog down.
>
> So yesterday I added this bitchin little tweak to allow the script to
> demote
> its own windows priority to "Below Normal", which in turn governs the
> priority of all the build tasks it spawns. Suddenly, it's a lot easier to
> get work done while the computer is building. Yay.
>
> But, I discovered today that not all of us developers have the same install
> of ActiveState (and it's not possible to mandate them to all upgrade to
> 5.10), and older versions of Win32::Process do not offer the symbols
> BELOW_NORMAL_PRIORITY_CLASS and ABOVE_NORMAL_PRIORITY_CLASS (presumably
> because win2K or pre-win2K did not have those priorities), so they cannot
>
> use Win32::Process qw[ BELOW_NORMAL_PRIORITY_CLASS
> ABOVE_NORMAL_PRIORITY_CLASS ];
>
> and the perl script borks.
>
> What I could do is modify the script so that the only possible
> priority-switching option is to change to LOW.
>
> What I'd rather do is allow every user access to every priority that their
> Win32::Process makes available to them. Is there a perl statement that will
> tell me whether Win32::Process is able to export the symbols I want,
> without
> actually trying to import them and killing the script?
>
> For reference, the trivial script below works for me, but not for the
> outdated. If this could be made to detect whether the symbols are
> available,
> and switch to low/high if they are not, that would solve my problem.
>
>
>
> use Win32::Process;
> use Win32::Process qw[ BELOW_NORMAL_PRIORITY_CLASS
> ABOVE_NORMAL_PRIORITY_CLASS ];
>
> my $pid = Win32::Process::GetCurrentProcessID();
> print "PID is $pid\n";
>
> $i = 100;
> $dt = 5;
> while ($i) {
> print "Sleeping for $dt seconds; $i\n";
> sleep $dt;
> $i--;
>
> my $proc;
> if (Win32::Process::Open($proc, $pid, 0)) {
> my $class;
> $proc->GetPriorityClass($class);
> print "Priority class is $class\n";
> if ($i%2) {
> print "Changing class to BELOW NORMAL\n";
> $proc->SetPriorityClass(BELOW_NORMAL_PRIORITY_CLASS);
> } else {
> print "Changing class to ABOVE NORMAL\n";
> $proc->SetPriorityClass(ABOVE_NORMAL_PRIORITY_CLASS);
> }
>
> } else {
> print "Can't find myself as PID=$pid\n";
> }
>
> }
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mail.pm.org/pipermail/san-diego-pm/attachments/20110510/63e364d5/attachment-0001.html
> >
>
> ------------------------------
>
> Message: 2
> Date: Tue, 10 May 2011 21:01:36 -0700
> From: Bob Kleemann <rkleeman at energoncube.net>
> To: Reuben Settergren <ruberad at gmail.com>
> Cc: san-diego-pm at pm.org
> Subject: Re: [San-Diego-pm] Wrangle module version?
> Message-ID: <BANLkTimnxQapK=EyD3R4i63Wg0T7j8+PaA at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> Since I don't have a Windows box to test this on, I'm not sure, but
> you could try something like
>
> our $LOW_PRIORITY;
> BEGIN {
> require Win32::Process;
> eval {
> Win32::Process->import(qw[
> BELOW_NORMAL_PRIORITY_CLASS
> ABOVE_NORMAL_PRIORITY_CLASS
> ]);
> $LOW_PRIORITY = BELOW_NORMAL_PRIORITY_CLASS;
> }
> || eval {
> Win32::Process->import(qw[ LOW ])
> $LOW_PRIORITY = LOW;
> };
> }
>
> Then proceed to use $LOW_PRIORITY where you would normally use
> BELOW_NORMAL_PRIORITY_CLASS.
>
> 2011/5/10 Reuben Settergren <ruberad at gmail.com>:
> > Hello Mongers,
> >
> > I have what seems like it should be a simple problem (and it probably
> is!),
> > but I'm not finding the simple solution, so I'm hoping somebody can give
> me
> > the right answer off the top of their head.
> >
> > So the group I work with shares a perl script to run multi-hour builds
> (of
> > C++, on windows boxes, with visual studio 9). Usually we try to rebuild
> the
> > whole shebang overnight, and then work on it all day. But sometimes we
> have
> > to build during the day, and the computer can bog down.
> >
> > So yesterday I added this bitchin little tweak to allow the script to
> demote
> > its own windows priority to "Below Normal", which in turn governs the
> > priority of all the build tasks it spawns. Suddenly, it's a lot easier to
> > get work done while the computer is building. Yay.
> >
> > But, I discovered today that not all of us developers have the same
> install
> > of ActiveState (and it's not possible to mandate them to all upgrade to
> > 5.10), and older versions of Win32::Process do not offer the symbols
> > BELOW_NORMAL_PRIORITY_CLASS and ABOVE_NORMAL_PRIORITY_CLASS (presumably
> > because win2K or pre-win2K did not have those priorities), so they cannot
> >
> > ??? use Win32::Process qw[ BELOW_NORMAL_PRIORITY_CLASS
> > ABOVE_NORMAL_PRIORITY_CLASS ];
> >
> > and the perl script borks.
> >
> > What I could do is modify the script so that the only possible
> > priority-switching option is to change to LOW.
> >
> > What I'd rather do is allow every user access to every priority that
> their
> > Win32::Process makes available to them. Is there a perl statement that
> will
> > tell me whether Win32::Process is able to export the symbols I want,
> without
> > actually trying to import them and killing the script?
> >
> > For reference, the trivial script below works for me, but not for the
> > outdated. If this could be made to detect whether the symbols are
> available,
> > and switch to low/high if they are not, that would solve my problem.
> >
> >
> >
> > use Win32::Process;
> > use Win32::Process qw[ BELOW_NORMAL_PRIORITY_CLASS
> > ABOVE_NORMAL_PRIORITY_CLASS ];
> >
> > my $pid = Win32::Process::GetCurrentProcessID();
> > print "PID is $pid\n";
> >
> > $i = 100;
> > $dt = 5;
> > while ($i) {
> > ? print "Sleeping for $dt seconds; $i\n";
> > ? sleep $dt;
> > ? $i--;
> >
> > ? my $proc;
> > ? if (Win32::Process::Open($proc, $pid, 0)) {
> > ??? my $class;
> > ??? $proc->GetPriorityClass($class);
> > ??? print "Priority class is $class\n";
> > ??? if ($i%2) {
> > ????? print "Changing class to BELOW NORMAL\n";
> > ????? $proc->SetPriorityClass(BELOW_NORMAL_PRIORITY_CLASS);
> > ??? } else {
> > ????? print "Changing class to ABOVE NORMAL\n";
> > ????? $proc->SetPriorityClass(ABOVE_NORMAL_PRIORITY_CLASS);
> > ??? }
> >
> > ? } else {
> > ??? print "Can't find myself as PID=$pid\n";
> > ? }
> >
> > }
> >
> >
> >
> >
> >
> >
> > _______________________________________________
> > San-Diego-pm mailing list
> > San-Diego-pm at pm.org
> > http://mail.pm.org/mailman/listinfo/san-diego-pm
> >
>
>
> ------------------------------
>
> Message: 3
> Date: Wed, 11 May 2011 10:08:52 -0700
> From: Joel Fentin <joel at fentin.com>
> To: Christopher Hart <christopher.p.hart at gmail.com>
> Cc: San Diego Perl Mongers <san-diego-pm at pm.org>, lasvegas-pm at pm.org
> Subject: Re: [San-Diego-pm] help
> Message-ID: <4DCAC2A4.3040703 at fentin.com>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> On 5/9/2011 1:39 PM, Christopher Hart wrote:
> > Hi Joel,
> >
> > I've seen browsers behave poorly over the . (cwd) in @INC.
> > Have you tried doing 'use lib qw(.);' or 'use lib qw(
> > /path/to/public_html/cgi-bin );' ?
>
> Chris,
>
> Thank you for getting back to me.
>
> To the extent that I understand (which ain't much), you think the
> problem is tied to the browser. If so, I would expect different
> results with Chrome, IE, & FF. I get identical results.
>
> I once dropped this same module into cgi-bin in Hurricane Electric
> and didn't have these problems. My own suspicion is that
> networksolutions has set up security such that I have to present
> the path in a certain format. I called them and they have various
> levels of experts. The guy at the third level is taking his sweet
> time getting back to me.
>
> More later if I learn anything.
>
> > On Mon, May 9, 2011 at 11:24 AM, Joel Fentin <joel at fentin.com
> > <mailto:joel at fentin.com>> wrote:
> >
> > Had to install Image::Size in cgi-bin. networksolutions won't
> > install perl modules.
> >
> > error message:
> >
> > Can't locate auto/Image/Size/jpegsize.al <http://jpegsize.al>
> > in @INC
> > (@INC contains: ../
> > ../Image
> > ../auto/Image/
> > ./auto/Image/Size/
> > auto/Image/Size/jpegsize.al <http://jpegsize.al>
> > auto/Image/Size/
> > ../auto/Image/Size/
> > /usr/lib/perl5/5.8.7/i686-linux
> > /usr/lib/perl5/5.8.7
> > /usr/lib/perl5/site_perl/5.8.7/i686-linux
> > /usr/lib/perl5/site_perl/5.8.7
> > /usr/lib/perl5/site_perl
> > /usr/lib/perl5/vendor_perl/5.8.7/i686-linux
> > /usr/lib/perl5/vendor_perl/5.8.7
> > /usr/lib/perl5/vendor_perl .)
> > at ..//Image/Size.pm line 213
> >
> > Addional notes:
> >
> > + I have dropped jpegsize.al <http://jpegsize.al> all over the
> > place and have changed permissions to 755.
> >
> > + I have added everything I can think of to @INC.
> >
> > + current directory is /public_html/cgi-bin/Admin as is the
> > application program.
> >
> > + Where the files are:
> > /public_html/cgi-bin/auto/Image/Size/jpegsize.al
> > <http://jpegsize.al> (& elsewhere)
> > /public_html/cgi-bin/Image/Size.pm
> >
> > I'm going in circles and don't know what it wants.
> >
> > --
> > Joel Fentin tel: 760-749-8863 <tel:760-749-8863>
> > Biz Website: http://fentin.com
> > Personal Website: http://fentin.com/me
> > _______________________________________________
> > San-Diego-pm mailing list
> > San-Diego-pm at pm.org <mailto:San-Diego-pm at pm.org>
> > http://mail.pm.org/mailman/listinfo/san-diego-pm
> >
> >
> >
> >
> > --
> > Respectfully,
> >
> > Chris Hart
> > Senior Internet Engineer,
> > ZeroLag Communications, Inc.
> > http://www.zerolag.com
> >
>
>
> --
> Joel Fentin tel: 760-749-8863
> Biz Website: http://fentin.com
> Personal Website: http://fentin.com/me
>
>
> ------------------------------
>
> Message: 4
> Date: Wed, 11 May 2011 11:08:23 -0700
> From: Chris Grau <chris at chrisgrau.com>
> To: Joel Fentin <joel at fentin.com>
> Cc: San Diego Perl Mongers <san-diego-pm at pm.org>
> Subject: Re: [San-Diego-pm] help
> Message-ID: <BANLkTinW9CcJ1YKyfMqJwswearpBH7=Deg at mail.gmail.com>
> Content-Type: text/plain; charset=UTF-8
>
> Your paths appear correct, according to the @INC listed in the error.
> The only oddity is the file itself appearing in @INC, but I assume
> it's because you were trying everything, including adding the file to
> the list.
>
> What's the file type of your jpegsize.al file (output of 'file jpegsize.al
> ')?
>
> What's the system type of the host (output of 'uname -a')?
>
> On Mon, May 9, 2011 at 11:24 AM, Joel Fentin <joel at fentin.com> wrote:
> > Had to install Image::Size in cgi-bin. networksolutions won't install
> perl
> > modules.
> >
> > error message:
> >
> > Can't locate auto/Image/Size/jpegsize.al in @INC
> > (@INC contains: ../
> > ../Image
> > ../auto/Image/
> > ./auto/Image/Size/
> > auto/Image/Size/jpegsize.al
> > auto/Image/Size/
> > ../auto/Image/Size/
> > /usr/lib/perl5/5.8.7/i686-linux
> > /usr/lib/perl5/5.8.7
> > /usr/lib/perl5/site_perl/5.8.7/i686-linux
> > /usr/lib/perl5/site_perl/5.8.7
> > /usr/lib/perl5/site_perl
> > /usr/lib/perl5/vendor_perl/5.8.7/i686-linux
> > /usr/lib/perl5/vendor_perl/5.8.7
> > /usr/lib/perl5/vendor_perl .)
> > at ..//Image/Size.pm line 213
> >
> > Addional notes:
> >
> > + I have dropped jpegsize.al all over the place and have changed
> permissions
> > to 755.
> >
> > + I have added everything I can think of to @INC.
> >
> > + current directory is /public_html/cgi-bin/Admin as is the application
> > program.
> >
> > + Where the files are:
> > /public_html/cgi-bin/auto/Image/Size/jpegsize.al (& elsewhere)
> > /public_html/cgi-bin/Image/Size.pm
> >
> > I'm going in circles and don't know what it wants.
>
>
> ------------------------------
>
> _______________________________________________
> San-Diego-pm mailing list
> San-Diego-pm at pm.org
> http://mail.pm.org/mailman/listinfo/san-diego-pm
>
> End of San-Diego-pm Digest, Vol 85, Issue 3
> *******************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/san-diego-pm/attachments/20110511/fa492afe/attachment-0001.html>
More information about the San-Diego-pm
mailing list