Use boto3 instead of urllib for getting csv files

This commit is contained in:
Patrick McDonagh
2018-05-08 10:36:45 -05:00
parent bcc1799e0e
commit 6ecadbe8a2
2 changed files with 7 additions and 7 deletions

View File

@@ -4,7 +4,7 @@ import json
import click
import boto3
import csv
import urllib2
CONFIG_FILE_NAME = "driverConfig.json"
CONFIG_OUTPUT_FILENAME = "config.txt"
@@ -33,9 +33,10 @@ def get_driver_files():
def get_driver_ids():
"""Retrieve the master list of driver IDs from the S3 bucket."""
ids = []
url = 'https://s3.amazonaws.com/{}/deviceIds.csv'.format(DRIVER_BUCKET)
response = urllib2.urlopen(url)
csvreader = csv.DictReader(response)
csvfileObj = s3.Object(DRIVER_BUCKET, 'deviceIds.csv')
csvString = csvfileObj.get()['Body'].read().decode('utf-8')
csvreader = csv.DictReader(csvString.splitlines())
for row in csvreader:
ids.append(row)
return ids
@@ -57,8 +58,7 @@ def check_driver_id(driver_name):
s3.Bucket(DRIVER_BUCKET).put_object(Key=file_key, Body=new_csv_contents)
s3.ObjectAcl(DRIVER_BUCKET, file_key).put(ACL='public-read')
return new_id
@click.group()
def cli():

View File

@@ -2,7 +2,7 @@ from setuptools import setup
setup(
name="pocloud_driver_setup",
version='0.1',
version='0.1.1',
py_modules=['pocloud_driver_setup'],
install_requires=[
'Click',