From 46541a64e9ca47d235f4fd832024bfcfa61db673 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Thu, 5 Feb 2015 16:58:23 +0000 Subject: Install Locale::gettext via cpanfile. --- .travis.yml | 2 +- cpanfile | 1 + cpanfile.snapshot | 6 ++++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2c80b3534..07e8bfa95 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,7 +20,7 @@ before_install: - sudo apt-get update -qq - sudo apt-get install -qq jhead libgmp-dev python-boto # A couple of other modules that normally come from packages, but no system stuff here - - cpanm -q Locale::gettext Math::BigInt::GMP + - cpanm -q Math::BigInt::GMP - sudo locale-gen cy_GB.UTF-8 en_GB.UTF-8 nb_NO.UTF-8 de_CH.UTF-8 sv_SE.UTF-8 install: - .travis/install diff --git a/cpanfile b/cpanfile index e6cb1d83d..ba92755f9 100644 --- a/cpanfile +++ b/cpanfile @@ -55,6 +55,7 @@ requires 'Image::Size'; requires 'IO::String'; requires 'JSON'; requires 'JSON::XS'; +requires 'Locale::gettext'; requires 'LWP::Simple'; requires 'LWP::UserAgent'; requires 'Math::Trig'; diff --git a/cpanfile.snapshot b/cpanfile.snapshot index e5d8b9afc..a5859b742 100644 --- a/cpanfile.snapshot +++ b/cpanfile.snapshot @@ -6599,6 +6599,12 @@ DISTRIBUTIONS common::sense 3.6 requirements: ExtUtils::MakeMaker 0 + gettext-1.05 + pathname: P/PV/PVANDRY/gettext-1.05.tar.gz + provides: + Locale::gettext 1.05 + requirements: + ExtUtils::MakeMaker 0 libwww-perl-6.05 pathname: G/GA/GAAS/libwww-perl-6.05.tar.gz provides: -- cgit v1.2.3 From 1cf8f514a231924cd992a5ca4f6af692c365da4a Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Thu, 5 Feb 2015 16:59:28 +0000 Subject: [Travis] Only install boto when necessary. And make sure file is removed if not a tar file. --- .travis.yml | 2 +- .travis/after_script | 10 +++++++--- .travis/install | 2 ++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 07e8bfa95..d332f4d97 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,7 @@ env: before_install: - sudo apt-get update -qq - - sudo apt-get install -qq jhead libgmp-dev python-boto + - sudo apt-get install -qq jhead libgmp-dev # A couple of other modules that normally come from packages, but no system stuff here - cpanm -q Math::BigInt::GMP - sudo locale-gen cy_GB.UTF-8 en_GB.UTF-8 nb_NO.UTF-8 de_CH.UTF-8 sv_SE.UTF-8 diff --git a/.travis/after_script b/.travis/after_script index 37fd37eb8..006ff7849 100755 --- a/.travis/after_script +++ b/.travis/after_script @@ -2,13 +2,11 @@ import hashlib import os +import site import subprocess import sys import tarfile -import boto -from boto.s3.key import Key - root = os.path.join(os.path.dirname(__file__), '..') with open(os.path.join(root, 'cpanfile.snapshot')) as cpanfile: hash = hashlib.md5(cpanfile.read()).hexdigest() @@ -18,6 +16,12 @@ if os.path.exists(wanted_filename) and os.path.getsize(wanted_filename): print "File was downloaded, no need to upload" sys.exit() +site.addsitedir(site.getusersitepackages()) +os.system('pip install --user boto') + +import boto +from boto.s3.key import Key + print "Creating archive..." tfile = tarfile.open(wanted_filename, 'w:gz') tfile.add('local') diff --git a/.travis/install b/.travis/install index c766d3598..b73eef330 100755 --- a/.travis/install +++ b/.travis/install @@ -19,6 +19,8 @@ try: tfile.extractall() print "Cached copy found and extracted" sys.exit(0) + else: + os.remove(wanted_filename) except IOError: os.remove(wanted_filename) -- cgit v1.2.3 From 46128a0f1998b01b6d698a22c8811f4898b69b0f Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Thu, 5 Feb 2015 17:00:51 +0000 Subject: Remove warning if Math::BigInt::GMP not installed. --- .travis.yml | 4 +--- commonlib | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index d332f4d97..d2579b5c7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,9 +18,7 @@ env: before_install: - sudo apt-get update -qq - - sudo apt-get install -qq jhead libgmp-dev -# A couple of other modules that normally come from packages, but no system stuff here - - cpanm -q Math::BigInt::GMP + - sudo apt-get install -qq jhead - sudo locale-gen cy_GB.UTF-8 en_GB.UTF-8 nb_NO.UTF-8 de_CH.UTF-8 sv_SE.UTF-8 install: - .travis/install diff --git a/commonlib b/commonlib index 4e67698fa..f87aecb75 160000 --- a/commonlib +++ b/commonlib @@ -1 +1 @@ -Subproject commit 4e67698fa8d8b25b71b1baaf1a1856dcd566e5a6 +Subproject commit f87aecb7510fb6e43156328277ba4aa4b9e17d74 -- cgit v1.2.3 From 6bc3566f0281f4aede0e11e8ab5e21476bc0b674 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Thu, 5 Feb 2015 17:01:41 +0000 Subject: Have code fallback to Image::Size if no jhead. Don't bother installing it on Travis. --- .travis.yml | 2 -- perllib/FixMyStreet/App/Controller/Photo.pm | 7 ++++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index d2579b5c7..b162c4c06 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,8 +17,6 @@ env: - secure: "qW+WCgAF68itADxcbcq+nCnKx3vf3GX73HMfjfbkFFUsYmIR+ZaJ9yQMnGJwxIpCHTWLAeqyx4KO8N8T3GmNdKYzIMZemOzp4ED29YC31QOQeq1CwNp2hD5sq/o47d2BzXWwMYNvNXfxz1K6r2c6EMPUtu8X3B8ExZq1RzSFdXs=" before_install: - - sudo apt-get update -qq - - sudo apt-get install -qq jhead - sudo locale-gen cy_GB.UTF-8 en_GB.UTF-8 nb_NO.UTF-8 de_CH.UTF-8 sv_SE.UTF-8 install: - .travis/install diff --git a/perllib/FixMyStreet/App/Controller/Photo.pm b/perllib/FixMyStreet/App/Controller/Photo.pm index 09afabecf..d70be50e6 100644 --- a/perllib/FixMyStreet/App/Controller/Photo.pm +++ b/perllib/FixMyStreet/App/Controller/Photo.pm @@ -8,6 +8,7 @@ use DateTime::Format::HTTP; use Digest::SHA qw(sha1_hex); use File::Path; use File::Slurp; +use Image::Size; use Path::Class; use if !$ENV{TRAVIS}, 'Image::Magick'; @@ -181,7 +182,11 @@ sub process_photo_upload : Private { my $photo_blob = eval { my $filename = $upload->tempname; my $out = `jhead -se -autorot $filename 2>&1`; - die _("Please upload a JPEG image only"."\n") if $out =~ /Not JPEG:/; + unless (defined $out) { + my ($w, $h, $err) = Image::Size::imgsize($filename); + die _("Please upload a JPEG image only") . "\n" if !defined $w || $err ne 'JPG'; + } + die _("Please upload a JPEG image only") . "\n" if $out && $out =~ /Not JPEG:/; my $photo = $upload->slurp; return $photo; }; -- cgit v1.2.3