Changeset b58aada for client


Ignore:
Timestamp:
Jul 5, 2010, 8:01:47 PM (14 years ago)
Author:
Jessica B. Hamrick <jhamrick@…>
Branches:
master, debian, mac, no-cups, web
Children:
d768767
Parents:
38388ac
git-author:
Jessica B. Hamrick <jhamrick@…> (07/05/10 20:01:47)
git-committer:
Jessica B. Hamrick <jhamrick@…> (07/05/10 20:01:47)
Message:

Use perl bindings for gbr and gbrm in addition to gbq. Update README.

Location:
client/bin
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • client/bin/gbq

    r30beeab rb58aada  
    3838
    3939print "Queue listing for queue '$queue' on '$host'\n\n";
    40 print "Job ID\t\tOwner\t\tFile\n";
     40print "Job ID\t\tOwner\t\tTitle\n";
    4141print "-----------------------------------------------------------------\n";
    4242
  • client/bin/gbr

    r38388ac rb58aada  
    55use strict;
    66use warnings;
     7
     8use Net::CUPS;
     9use Net::CUPS::Destination;
     10use Image::ExifTool qw(ImageInfo);
    711
    812my $usage = "Usage: gbr QUEUE FILES\n";
     
    3135}
    3236
    33 $ENV{CUPS_SERVER}="$host";
     37my $cups = Net::CUPS->new();
     38$cups->setServer("$host");
     39my $printer = $cups->getDestination("$queue");
     40my ($jobid, $title);
    3441
    3542foreach my $file(@files) {
    3643    if ($file =~ m|http://www\.youtube\.com/watch\?v=|) {
    37         open(LP, "|-", "lp", "-d$queue") or die "Couldn't execute lp command";
    38         print LP "$file";
    39         close LP;
     44        open FILE, ">", "/tmp/gutenbach-youtube\n" or die "Couldn't create temporary file";
     45        print FILE $file;
     46        $title = $file;
     47        $file = "/tmp/gutenbach-youtube";
     48        $printer->addOption("copies", 42);
    4049    }
    4150    else {
    42         my $pid = open(LP, "-|");
    43         if (not $pid) {
    44             my @args = ("lp", "-d$queue", "$file");
    45             exec(@args) or die "Couldn't execute lp command";
     51        my $fileinfo = ImageInfo($file);
     52        my $magic = $fileinfo->{FileType};
     53
     54        if ($magic) {
     55            $title = $fileinfo->{'Title'}." - ".$fileinfo->{'Artist'}." - ".$fileinfo->{'Album'};
     56        }
     57        else {
     58            $title = $file;
    4659        }
    4760    }
    4861
    49     print "Sent job '$file'\n";
     62    $jobid = $printer->printFile($file, $title);
     63   
     64    if ($jobid) {
     65        print "Sent job '$title' (id $jobid)\n";
     66    }
     67    else {
     68        print "Error sending job '$title'\n";
     69    }
    5070}
  • client/bin/gbrm

    ra81397c rb58aada  
    3434}
    3535
    36 my @args;
     36my $cups = Net::CUPS->new();
     37$cups->setServer("$host");
     38my $printer = $cups->getDestination("$queue");
     39my @jobs = $printer->getJobs(0, 0);
    3740
    3841if ($id eq "all") {
    39     @args = ("cancel", "-a", "$queue");
     42    foreach $id(@jobs) {
     43        $printer->cancelJob($id);
     44    }
    4045}
    4146elsif ($id eq "current") {
    42     my $cups = Net::CUPS->new();
    43     $cups->setServer("$host");
    44     my $printer = $cups->getDestination("$queue");
    45     my @jobs = $printer->getJobs(0, 0);
    46     my $id = $jobs[0];
    47     @args = ("cancel", "$id", "$queue");
     47    $id = $jobs[0];
     48    $printer->cancelJob($id);
    4849}
    4950else {
    50     @args = ("cancel", "$id", "$queue");
     51    $printer->cancelJob($id);
    5152}
    52 $ENV{CUPS_SERVER}="$host";
    53 exec (@args) or die "Couldn't execute cancel command";
Note: See TracChangeset for help on using the changeset viewer.