#!/usr/bin/python

import commands
filename='/netdisks/panstarrs/ipp/mysql-dump/.curr_gpc1_name'
f=open(filename, 'r+')
currname=f.read()
f.close()

if(currname=='gpc1_0'):
	newname='gpc1_1'
else:
	newname='gpc1_0'

print newname
gpc1dumps=commands.getoutput('ls -t -1 /export/ipp001.0/ipp/mysql-dumps/mysql-gpc1*')
dumparray=gpc1dumps.split()[1]
cmd='bunzip2 < '+dumparray+' | mysql -hipp001 -u ipp -pipp -f ' + newname
results = commands.getstatusoutput(cmd)

f=open(filename, 'w')
f.write(newname)
f.close()

print results
