Skip to content

Commit

Permalink
travis.py: Better shell and try sql
Browse files Browse the repository at this point in the history
  • Loading branch information
tobes committed Apr 15, 2013
1 parent 7d3b0c1 commit 887081d
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions bin/travis.py
Expand Up @@ -7,22 +7,29 @@
PG_VERSION = os.environ.get('PGVERSION')
PYTHON_2_6 = sys.version_info < (2, 7)

sql = '''
CREATE USER ckanuser WITH PASSWORD 'pass';
CREATE USER readonlyuser WITH PASSWORD 'pass';
CREATE DATABASE ckan_test WITH OWNER ckanuser;
CREATE DATABASE ckan_test_datastore WITH OWNER ckanuser;
'''


def shell(arg):
def shell(arg, split_on='~'):
''' pass a list or arg string that will be split on separator. '''
# FIXME we should raise errors when we have them.
if isinstance(arg, basestring):
arg = arg.split(split_on)
subprocess.call(arg)

# Install postgres and solr
# We need this ppa so we can install postgres-8.4
shell(['sudo', 'add-apt-repository', '-yy', 'ppa:pitti/postgresql'])
shell(['sudo', 'apt-get', 'update', '-qq'])
shell(['sudo', 'apt-get', 'install', 'solr-jetty', 'postgresql-%s' % PG_VERSION])
shell('sudo~add-apt-repository~-yy~ppa:pitti/postgresql')
shell('sudo~apt-get~update~-qq')
shell('sudo~apt-get~install~solr-jetty~postgresql-%s' % PG_VERSION)

sql = '''
CREATE USER ckanuser WITH PASSWORD \'pass\';
CREATE USER readonlyuser WITH PASSWORD \'pass\';
CREATE DATABASE ckan_test WITH OWNER ckanuser;
CREATE DATABASE ckan_test_datastore WITH OWNER ckanuser;
'''

shell('psql~\'%s\'' % sql)

shell(['psql', '-U', 'ckanuser', 'ckan_test', '-c', 'SELECT version();'])
shell('psql~-U~ckanuser~ckan_test~-c~SELECT version();')

0 comments on commit 887081d

Please sign in to comment.