Changeset 222
- Timestamp:
- 02/20/09 04:38:07 (9 months ago)
- Files:
-
- management/bs-admin/trunk/cache_and_sync.py (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
management/bs-admin/trunk/cache_and_sync.py
r220 r222 12 12 from ConfigParser import ConfigParser 13 13 import time,os 14 from time import strftime 15 from datetime import datetime 14 16 from difflib import * 15 17 from subprocess import * … … 202 204 203 205 def sync_project_profiles(): 206 204 207 # Create Social DB 205 208 file = open("/var/www/social/config.php") … … 221 224 cursor = conn.cursor() 222 225 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 223 239 224 240 # New Profile Sync … … 252 268 cursor.execute(sql) 253 269 conn.commit() 270 271 254 272 else: 255 273 sql = "INSERT INTO elgg_users (username, active, owner, user_type, moderation) VALUES ('%s', 'yes', '-1', 'person', 'no')" % (p.owner.username) … … 353 371 conn.commit() 354 372 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 355 390 sql = "SELECT value FROM elgg_profile_data WHERE owner='%s' AND name='workweb'" % (project_id) 356 391 cursor.execute(sql) … … 369 404 conn.commit() 370 405 371 372 406 #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() 378 412 sync_project_profiles()

