<commit_before>__author__ = 'mariosky'

import psycopg2
import os
import sys
from django.conf import settings
from django.core.wsgi import get_wsgi_application



SITE_ID =""




if len(sys.argv) == 2:
    SITE_ID = sys.argv[1]
else:
    print "You need to send the Site Id as a parameter."
    exit()

print "####### DJANGO SETTINGS"
os.environ['DJANGO_SETTINGS_MODULE'] = "protoboard.settings"
application = get_wsgi_application()

con = psycopg2.connect(database=settings.DATABASES['default']['NAME'],user=settings.DATABASES['default']['USER'],
                       host=settings.DATABASES['default']['HOST'],password=settings.DATABASES['default']['PASSWORD'],)
print con

cur = con.cursor()

cur.execute("""CREATE OR REPLACE VIEW activitytree_ula_vw AS
 SELECT ul.user_id, ul.learning_activity_id, ul.pre_condition, ul.progress_status, ul.objective_status, ul.objective_measure, la.parent_id, la.rollup_progress,  la.name
   FROM activitytree_learningactivity la
   JOIN activitytree_userlearningactivity ul ON la.id = ul.learning_activity_id;""")


cur.execute( """ALTER TABLE activitytree_ula_vw OWNER TO %s;""" % settings.DATABASES['default']['USER'])

cur.execute("""ALTER TABLE auth_user
  ADD CONSTRAINT auth_user_email_key UNIQUE(email);
COMMENT ON CONSTRAINT auth_user_email_key ON auth_user IS 'Unique email ';""")



cur.execute("""UPDATE django_site
   SET domain=%s, name=%s where id=1;""",(SITE_ID,SITE_ID))


con.commit()

cur.close()
con.close()<commit_msg>Update site name on INSTALL, Exceptions added<commit_after>__author__ = 'mariosky'

import psycopg2
import os
import sys
from django.conf import settings
from django.core.wsgi import get_wsgi_application



SITE_ID =""




if len(sys.argv) == 2:
    SITE_ID = sys.argv[1]
else:
    print "You need to send the Site Id as a parameter."
    exit()

print "####### DJANGO SETTINGS"
os.environ['DJANGO_SETTINGS_MODULE'] = "protoboard.settings"
application = get_wsgi_application()

con = psycopg2.connect(database=settings.DATABASES['default']['NAME'],user=settings.DATABASES['default']['USER'],
                       host=settings.DATABASES['default']['HOST'],password=settings.DATABASES['default']['PASSWORD'],)
print con

cur = con.cursor()

try:
    cur.execute("""CREATE OR REPLACE VIEW activitytree_ula_vw AS
 SELECT ul.user_id, ul.learning_activity_id, ul.pre_condition, ul.progress_status, ul.objective_status, ul.objective_measure, la.parent_id, la.rollup_progress,  la.name
   FROM activitytree_learningactivity la
   JOIN activitytree_userlearningactivity ul ON la.id = ul.learning_activity_id;""")
except Exception as e:
    print e.message
    print """CREATE OR REPLACE VIEW activitytree_ula_vw """


try:
    cur.execute( """ALTER TABLE activitytree_ula_vw OWNER TO %s;""" % settings.DATABASES['default']['USER'])
except Exception as e:
    print e.message
    print """Error on: ALTER TABLE activitytree_ula_vw OWNER TO """


try:
    cur.execute("""ALTER TABLE auth_user
      ADD CONSTRAINT auth_user_email_key UNIQUE(email);
      COMMENT ON CONSTRAINT auth_user_email_key ON auth_user IS 'Unique email ';""")
except Exception as e:
    print e.message
    print """Error on: ADD CONSTRAINT auth_user_email_key UNIQUE"""

try:
    cur.execute("""UPDATE django_site
   SET domain=%s, name=%s where id=1;""",(SITE_ID,SITE_ID))
except Exception as e:
    print e.message
    print """Error on: UPDATE django_site"""


con.commit()

cur.close()
con.close()
{'fraction_non_alphanumeric': 0.1253627394080093, 'fraction_numerical': 0.002901915264074289, 'mean_word_length': 5.090106007067138, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1167435', 'n_tokens_mistral': 1181, 'n_tokens_neox': 1145, 'n_words': 275}