Commit 73599deb authored by Martin Klimes (k11m1)'s avatar Martin Klimes (k11m1)
Browse files

generalized + fixed regex error

parent fa6dd707
......@@ -202,18 +202,18 @@ sub usage() {
say "Requires local CUPS server running and SAMBA client installed.";
say "usage: $0 <printer-name>";
say "Must be run as root.";
say
"Triumph-Adler 50007ci needs Python 2.7 as a dependency and will install 2 python modules automatically.";
say "Triumph-Adler 50007ci needs Python 2.7 as a dependency ";
say "and will install 2 python modules automatically.";
print "\n\n";
print_printers();
exit 1;
}
# NOTE SEEMS FIXED with $? == 0
sub check_python {
my $regex =
/^Python 2\.7*/; #FIXME Use of unitialized value $_ in pattern match
my $regex = qr/^Python 2\.7*/;
#FIXME Use of unitialized value $_ in pattern match
my $output = qx/python -V 2>&1/;
if ( $? == 0 && $output =~ $regex ) {
......@@ -266,9 +266,6 @@ sub pre_TA5007ci {
# START OF THE SCRIPT #
#######################
# TODO restructure this mess
# TODO put this as static data and not yml
if ( @ARGV == 0 || $ARGV[0] eq "-h" || $ARGV[0] eq "--help" ) {
usage;
}
......@@ -295,30 +292,24 @@ if ( not( exists( $printers->{$printer_name} ) ) ) {
# Check if we have Root
die "Must be run with root privileges\n" if $> != 0;
say $printers->{$printer_name}->{'model'};
my $model = $printers->{$printer_name}->{'model'};
say "Selected model is $model";
#TA5007ci requires python2 reportlab and PyPDF2
if ( $model eq "TA5007ci" ) {
pre_TA5007ci();
}
if ( $model eq "TA4505ci" ) {
generic_printer("$printer_name");
}
elsif ( $model eq "hp-laserjet-600" ) {
generic_printer $printer_name;
}
else {
generic_printer("$printer_name");
}
# NOTE there was a problem before // THIS DOESNT WORK?
# NOTE This could be written better but idk how
foreach ( $models->{$model}->{'filters'} ) {
foreach (@$_) {
say "Selected model is $_";
copy_filter($_);
}
}
say "DONE!";
install_printer("$printer_name");
say "Installation is completed";
say "You may alter the printer settings in cups interface.";
# hp_laserjet_600($printer_name);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment