def addServer(worksheet, fname, index): global serverList serial = LogReader.getSerial(fname); index += 1; serverList.append([serial,LogReader.getAsset(serial),LogReader.getModel(fname)]+LogReader.genInfo(fname,True)+[LogReader.getFails(fname),]) if index == 1: print serverList
def uploadPicture(fname): try: model = LogReader.getModel(fname) pictureList = getPictures(LogReader.getSerial(fname)) if len(pictureList) <= 0: pictureList = getPictures(model) pictureURLs = [] if len(pictureList) <= 0: return None for picture in pictureList: files = {'file': ('EbayImage', file(picture, 'rb'))} pictureData = { "WarningLevel": "High", "PictureName": model, "PictureSet":"Supersize" } response = api.execute('UploadSiteHostedPictures', pictureData, files=files) pictureURLs.append(response.dict()['SiteHostedPictureDetails']['FullURL']) return pictureURLs except ConnectionError as e: print(e) print(e.response.dict())
def verifyPost(fname,postInfo,postTitle): model = LogReader.getModel(fname) pictures = getPictures(LogReader.getSerial(fname)) if len(pictures) <= 0: pictures = getPictures(LogReader.getModel(fname)) printLine() print("Picture #: {}".format(len(pictures))) print("TITLE:{}".format(postTitle)) print "Buy It Now Price: ${}".format(ebayTools.getConfig(model,"BuyItNowPrice")) print "Starting Price: ${}".format(ebayTools.getConfig(model,"StartPrice")) printLine() print("DESCRIPTION:\n{}".format(postInfo.replace("<br>","\n"))) while True: print("Is this ok? (y/n)") line = sys.stdin.readline().rstrip() if line.lower() == "y" or line.lower() == "yes": return elif line.lower() == "n" or line.lower() == "no": print("Skipping...") return -1 else: print("Invalid input")
def postItem(fname): try: global cfgOverride model = LogReader.getModel(fname) postTitle = genTitle(fname) postInfo = genInfo(fname) if dynamicPrice: price = prices.getPrice(fname) if ebayTools.getConfig(model,"ListingType") == "FixedPriceItem": cfgOverride["StartPrice"] = int(price) else: cfgOverride["BuyItNowPrice"] = int(price) cfgOverride["StartPrice"] = int(price / 7) if VerifyFlag: if verifyPost(fname,postInfo,postTitle) is not None: return pictureURLs = uploadPicture(fname) template = file(os.path.join(dn,"template.html"),"r") htmlData = template.read().replace("{{ title }}", postTitle) htmlData += "<!---SERVICETAG={}-----!>".format(LogReader.getSerial(fname)) if pictureURLs is not None: pictureHTML = "" for url in pictureURLs: pictureHTML += '<img src="{}" style="display:none;">'.format(url) htmlData = htmlData.replace("{{ image src }}",'{}'.format(pictureHTML)) else: htmlData = htmlData.replace("{{ image src }}","") #htmlData = htmlData.replace("{{ image src }}","<img src='http://i.ebayimg.sandbox.ebay.com/00/s/OTAwWDE2MDA=/z/6FkAAOSwErpWHpfG/$_1.JPG?set_id=8800005007'>") htmlData = htmlData.replace("{{ description }}",postInfo) myitem = { "Item": { "Title": genTitle(fname), "Description": "<![CDATA["+htmlData+"]]>", "ItemSpecifics": genItemSpecifics(fname), } } global failFlag if failFlag: print("Something went wrong, skipping {}".format(fname)) failFlag = False return if pictureURLs is not None: myitem["Item"]["PictureDetails"] = {"PictureURL": [x for x in pictureURLs]} myitem = setItemConfig(model,myitem) d = api.execute('AddItem', myitem).dict() itemURL = getItemURL(d["ItemID"]) if LogURL: urlLog = file("urlLog.txt","w") #urlLog.write() urlLog.close() printLine() print(itemURL) printLine() except ConnectionError as e: print(e) print(e.response.dict())