import time
import pdb 
import subprocess
import gspread


mirrorPath = "/var/www/html/mirror/"


## Get Google connection
gc = gspread.login('[[[Your google account username]]]', '[[[Your google account password]]]')


## Get handle to spreadsheet
wks = gc.open([[[Name of your spreadsheet]]]).sheet1
cell_list = wks.get_all_values()

## Process all rows 
for eachRow in cell_list[1:]:
    ## print eachRow
    siteName = eachRow[0]
    siteUrl = eachRow[1]
    subProcessCommand = 'httrack '+siteUrl+' -O '+mirrorPath+siteName
    try:
        subprocess.call(subProcessCommand, shell=True)
    except:
        print "Mirror didn't work. Skipping to next"
    print "Site "+ siteName + " has been mirrored"