I am trying to use a Python script to automatically upload a file to eBay FileExchange on a daily basis. I have written the following Python script to check files in a folder named in the format of the date it is to be uploaded (eg. 2015-04-06):
Code: Select all
#!/usr/bin/python
import time, datetime
dateString = '%Y-%m-%d'
datetimeString = '%Y/%m/%d %H:%M:%S'
from os import listdir
from os.path import isfile, join
uploaddate = datetime.datetime.now().strftime(dateString)
print(datetime.datetime.now().strftime(datetimeString) + ": Checking upload folder '" + uploaddate + "' for files...")
onlyfiles = [ f for f in listdir('./upload/' + uploaddate) if isfile(join('./upload/' + uploaddate,f)) ]
print(datetime.datetime.now().strftime(datetimeString) + ': ' + str(len(onlyfiles)) + ' files found:')
for filename in onlyfiles:
print(filename)
curl -k https://bulksell.ebay.co.uk/ws/eBayISAPI.dll?FileExchangeUpload -F"token=MYTOKEN" -F file=@$filename
Code: Select all
curl -k https://bulksell.ebay.co.uk/ws/eBayISAPI.dll?FileExchangeUpload -F"token=MYTOKEN" -F file=@"myfile.csv"
I would like to know how to correctly format the line in my Python script to run the curl command for each file found in the folder. I know that the code I have to run curl is incorrect in my Python script, and have given up messing around with double and single quotes. If anyone knows how to correctly call the curl command in a Python script with variables in the command line please help!