Exemplo n.º 1
0
def updater(target="dev"):
    print ("Downloading new data file from Google...")
    try:
        get_data()
    except:
        slack_notify("Hello, I had a problem downloading the Sunday Talk show spreadsheet from Google.", slack_channel)
        raise
    print ("Converting to JSON...")
    # remove files if they already exist
    try:
        run("rm %s" % (data_json))
    except:
        pass
    try:
        run("rm %s" % (data_csv))
    except:
        pass
    try:
        run("rm %s" % (filter_json))
    except:
        pass
    try:
        run("rm %s" % (filter_csv))
    except:
        pass
    try:
        run("rm %s" % (copy_csv))
    except:
        pass
    try:
        run("rm %s" % (copy_json))
    except:
        pass
    # convert excel sheet into 3 CSVs
    try:
        run ("in2csv %s --sheet Sheet1 > %s" % (master_spreadsheet, data_csv))
        run ("in2csv %s --sheet filters > %s" % (master_spreadsheet, filter_csv))
        run ("in2csv %s --sheet copy > %s" % (master_spreadsheet, copy_csv))
        run ("in2csv %s --sheet shows > %s" % (master_spreadsheet, shows_csv))
        run("csvjson %s > %s" % (data_csv, data_json))
        run("csvjson %s > %s" % (filter_csv, filter_json))
        run("csvjson %s > %s" % (copy_csv, copy_json))
        run("csvjson %s > %s" % (shows_csv, shows_json))
    except:
        slack_notify("Hello, I was unable to convert the latest sunday talk show data correctly.", slack_channel)
        raise
    print("Formatting data...")
    try:
        format_data()
    except:
        slack_notify("Hello, I was unable to format the latest data file correctly.", slack_channel)
        raise
    print("Uploading data...")
    try:
        ftp_conn = connect_ftp()
        ftp_conn.cwd("usatoday/2015/03/sunday-shows/data/")
        upload_file(ftp_conn, create_absolute_path('data_tools/output/data.json'))
        slack_notify("Hello! The Sunday Talk Show interactive data has been updated successfully.", slack_channel)
    except:
        slack_notify("I had a problem uploading the new data to the server.", slack_channel)
Exemplo n.º 2
0
def updater(target="dev"):
    print("Downloading new data file from Google...")
    try:
        get_data()
    except:
        # slack_notify("Hello, I had a problem downloading the Sunday Talk show spreadsheet from Google.", slack_channel)
        raise

    print("Formatting data...")
    try:
        format_data()
    except:
        # slack_notify("Hello, I was unable to format the latest data file correctly.", slack_channel)
        raise
    # print("Uploading data...")
    try:
        print "moving data to source folder"
        local("cp data_tools/output/data.json src/data")
    except:
        print "Couldn't copy new data to src folder"
        pass
Exemplo n.º 3
0
def updater(target="dev"):
    print ("Downloading new data file from Google...")
    try:
        get_data()
    except:
        # slack_notify("Hello, I had a problem downloading the Sunday Talk show spreadsheet from Google.", slack_channel)
        raise
    
    print("Formatting data...")
    try:
        format_data()
    except:
        # slack_notify("Hello, I was unable to format the latest data file correctly.", slack_channel)
        raise
    # print("Uploading data...")
    try:
        print "moving data to source folder"
        local("cp data_tools/output/data.json src/data")
    except:
        print "Couldn't copy new data to src folder"
        pass
Exemplo n.º 4
0
def updater(target="dev"):
    print("Downloading new data file from Google...")
    try:
        get_data()
    except:
        slack_notify(
            "Hello, I had a problem downloading the Sunday Talk show spreadsheet from Google.",
            slack_channel)
        raise
    print("Converting to JSON...")
    # remove files if they already exist
    try:
        run("rm %s" % (data_json))
    except:
        pass
    try:
        run("rm %s" % (data_csv))
    except:
        pass
    try:
        run("rm %s" % (filter_json))
    except:
        pass
    try:
        run("rm %s" % (filter_csv))
    except:
        pass
    try:
        run("rm %s" % (copy_csv))
    except:
        pass
    try:
        run("rm %s" % (copy_json))
    except:
        pass
    # convert excel sheet into 3 CSVs
    try:
        run("in2csv %s --sheet Sheet1 > %s" % (master_spreadsheet, data_csv))
        run("in2csv %s --sheet filters > %s" %
            (master_spreadsheet, filter_csv))
        run("in2csv %s --sheet copy > %s" % (master_spreadsheet, copy_csv))
        run("in2csv %s --sheet shows > %s" % (master_spreadsheet, shows_csv))
        run("csvjson %s > %s" % (data_csv, data_json))
        run("csvjson %s > %s" % (filter_csv, filter_json))
        run("csvjson %s > %s" % (copy_csv, copy_json))
        run("csvjson %s > %s" % (shows_csv, shows_json))
    except:
        slack_notify(
            "Hello, I was unable to convert the latest sunday talk show data correctly.",
            slack_channel)
        raise
    print("Formatting data...")
    try:
        format_data()
    except:
        slack_notify(
            "Hello, I was unable to format the latest data file correctly.",
            slack_channel)
        raise
    print("Uploading data...")
    try:
        ftp_conn = connect_ftp()
        ftp_conn.cwd("usatoday/2015/03/sunday-shows/data/")
        upload_file(ftp_conn,
                    create_absolute_path('data_tools/output/data.json'))
        slack_notify(
            "Hello! The Sunday Talk Show interactive data has been updated successfully.",
            slack_channel)
    except:
        slack_notify("I had a problem uploading the new data to the server.",
                     slack_channel)