aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2015-02-16 14:49:24 +0000
committerMatthew Somerville <matthew@mysociety.org>2015-02-16 14:49:24 +0000
commit9bbc76b814f2c7798bb008e626d59a788fc81c6e (patch)
treeddc11ceb1b97b368fb3d1b7487e924a1215086ec
parentb1a719a95a736937f6d5c92bf81d95f0bc999152 (diff)
parent6bc3566f0281f4aede0e11e8ab5e21476bc0b674 (diff)
Merge in installation changes.
Fall back better if a couple of things aren't installed.
-rw-r--r--.travis.yml4
-rwxr-xr-x.travis/after_script10
-rwxr-xr-x.travis/install2
m---------commonlib0
-rw-r--r--cpanfile1
-rw-r--r--cpanfile.snapshot6
-rw-r--r--perllib/FixMyStreet/App/Controller/Photo.pm7
7 files changed, 22 insertions, 8 deletions
diff --git a/.travis.yml b/.travis.yml
index 2c80b3534..b162c4c06 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -17,10 +17,6 @@ env:
- secure: "qW+WCgAF68itADxcbcq+nCnKx3vf3GX73HMfjfbkFFUsYmIR+ZaJ9yQMnGJwxIpCHTWLAeqyx4KO8N8T3GmNdKYzIMZemOzp4ED29YC31QOQeq1CwNp2hD5sq/o47d2BzXWwMYNvNXfxz1K6r2c6EMPUtu8X3B8ExZq1RzSFdXs="
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
- 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/.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)
diff --git a/commonlib b/commonlib
-Subproject 4e67698fa8d8b25b71b1baaf1a1856dcd566e5a
+Subproject f87aecb7510fb6e43156328277ba4aa4b9e17d7
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:
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;
};