Changeset 222

Show
Ignore:
Timestamp:
02/20/09 04:38:07 (9 months ago)
Author:
gallardj
Message:

refs #2674. This updates cache_and_sync.py to add the project start date into the profile data.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • management/bs-admin/trunk/cache_and_sync.py

    r220 r222  
    1212from ConfigParser import ConfigParser 
    1313import time,os 
     14from time import strftime 
     15from datetime import datetime 
    1416from difflib import * 
    1517from subprocess import * 
     
    202204 
    203205def sync_project_profiles(): 
     206   
    204207  # Create Social DB 
    205208  file = open("/var/www/social/config.php") 
     
    221224  cursor = conn.cursor()     
    222225 
     226  #Trac DB 
     227  config = ConfigParser() 
     228  config.read('beaversource.ini') 
     229  tracuser = config.get('trac', 'dbadmin') 
     230  tracpass = config.get('trac', 'dbpass') 
     231   
     232  try: 
     233    tracconn = psycopg2.connect("dbname='projects' user='%s' host='localhost' password='%s'" % (tracuser, tracpass)) 
     234  except: 
     235    print "Unable to connect to the trac db" 
     236 
     237  trac_cursor = tracconn.cursor() 
     238   
    223239 
    224240  # New Profile Sync 
     
    252268      cursor.execute(sql) 
    253269      conn.commit() 
     270 
     271 
    254272    else: 
    255273      sql = "INSERT INTO elgg_users (username, active, owner, user_type, moderation) VALUES ('%s', 'yes', '-1', 'person', 'no')" % (p.owner.username) 
     
    353371          conn.commit() 
    354372         
     373        sql = "SELECT time FROM master_wiki WHERE name='WikiStart' AND author='trac' AND dbuser='bs_%s_user'" % (p.short_name) 
     374        trac_cursor.execute(sql) 
     375        trac_start_time = trac_cursor.fetchone()[0] 
     376        trac_time = datetime.fromtimestamp(trac_start_time) 
     377        trac_db_time = trac_time.strftime("%b %d, %Y - %I:%M %p") 
     378        sql = "SELECT value FROM elgg_profile_data WHERE owner='%s' AND name='start_time'" % (project_id) 
     379        cursor.execute(sql) 
     380        value = cursor.fetchone() 
     381        if value: 
     382          sql = "UPDATE elgg_profile_data SET value='%s' WHERE owner='%s' AND name='start_time'" % (trac_db_time, project_id) 
     383          cursor.execute(sql) 
     384          conn.commit() 
     385        else: 
     386          sql = "INSERT INTO elgg_profile_data VALUES (DEFAULT, '%s', 'LOGGED_IN', 'start_time', '%s')" % (project_id, trac_db_time) 
     387          cursor.execute(sql) 
     388          conn.commit() 
     389 
    355390        sql = "SELECT value FROM elgg_profile_data WHERE owner='%s' AND name='workweb'" % (project_id) 
    356391        cursor.execute(sql) 
     
    369404        conn.commit() 
    370405 
    371  
    372406#Call all the funcation 
    373 create_nonexistant_approved_projects() 
    374 sync_project_data() 
    375 create_authz() 
    376 create_apache_config() 
    377 check_license_wiki_files() 
     407#create_nonexistant_approved_projects() 
     408#sync_project_data() 
     409#create_authz() 
     410#create_apache_config() 
     411#check_license_wiki_files() 
    378412sync_project_profiles()