File tree 2 files changed +44
-0
lines changed
2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env python
2
+ import json
3
+ import psycopg2
4
+ from os import path
5
+ from time import sleep
6
+ from sys import stdout as out
7
+
8
+ if path .exists ('/home/dotcloud/environment.json' ):
9
+ with open ('/home/dotcloud/environment.json' ) as f :
10
+ env = json .load (f )
11
+ else :
12
+ env = {
13
+ 'DOTCLOUD_DB_SQL_LOGIN' : 'root' ,
14
+ 'DOTCLOUD_DB_SQL_PASSWORD' : 'root' ,
15
+ 'DOTCLOUD_DB_SQL_HOST' : 'localhost' ,
16
+ 'DOTCLOUD_DB_SQL_PORT' : '5432' ,
17
+ }
18
+
19
+ dbname = "test"
20
+
21
+ out .write ("Creating the database..." )
22
+ out .flush ()
23
+ for i in xrange (1 ,30 ):
24
+ try :
25
+ conn = psycopg2 .connect (
26
+ user = env ['DOTCLOUD_DB_SQL_LOGIN' ],
27
+ password = env ['DOTCLOUD_DB_SQL_PASSWORD' ],
28
+ host = env ['DOTCLOUD_DB_SQL_HOST' ],
29
+ port = env ['DOTCLOUD_DB_SQL_PORT' ],
30
+ database = 'postgres' )
31
+ conn .set_isolation_level (0 )
32
+ cur = conn .cursor ()
33
+ cur .execute ("CREATE DATABASE %s" % dbname )
34
+ out .write ("\n " )
35
+ break
36
+ except Exception as e :
37
+ raise e
38
+ sleep (1 )
39
+ out .write ("." )
40
+ out .flush ()
41
+
42
+ if __name__ == '__main__' :
43
+ import sys
Original file line number Diff line number Diff line change 1
1
www :
2
2
type : python
3
+ postinstall : ./app/postgresql.py
3
4
db :
4
5
type : postgresql
You can’t perform that action at this time.
0 commit comments