Пример #1
0
def genInfo(fname):
	notes = ebayTools.getConfig(LogReader.getModel(fname),"SpecialNotes")
	info = LogReader.genInfo(fname).replace(",\n","<br>");
	info += "<br>"
	if notes is not None:
		info += "<br>{}".format(notes)
	return info
Пример #2
0
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
Пример #3
0
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")
Пример #4
0
def genItemSpecifics(fname):
	model = LogReader.getModel(fname)

	mConfig = ebayTools.getConfig(model,"ItemSpecifics")
	specList = []
	specDict = {}
	if mConfig is not None:
		for k,v in mConfig.items():
			addItemSpecific(k,v,specList)
	addItemSpecific("Memory (RAM) Capacity",LogReader.getTotalRam(fname)[0],specList)
	addItemSpecific("Model",model.split(" ")[-1],specList)
	addItemSpecific("Product Line",model.split(" ")[0],specList)
	addItemSpecific("MPN",model.split(" ")[-1],specList)
	addItemSpecific("CPU Cores",LogReader.getProcCores(fname),specList)
	addItemSpecific("Number of Processors",sum([v for k,v in LogReader.getProcInfo(fname).items()]),specList)
	addItemSpecific("Memory Type",LogReader.getTotalRam(fname)[1],specList)
	addItemSpecific("Processor Speed",LogReader.getProcSpeed(fname),specList)
	specDict["NameValueList"] = specList
	return specDict
Пример #5
0
def genTitle(fname):
	ramInfo = LogReader.getTotalRam(fname)
	procInfo = LogReader.getProcInfo(fname)
	HDinfo = LogReader.getHarddrives(fname)
	
	global failFlag
	if procInfo is None:
		failFlag = True
		return "-1"

	procTitle = ", "+" ".join(["{} x{}".format(k,v) for k,v in procInfo.items()])
	procTitle = procTitle.replace("Intel(R)","")


	title = LogReader.getModel(fname)
	title += procTitle
	title += ", {} {}".format(ramInfo[0],ramInfo[1])
	if HDinfo is not None:
		title += ", "+LogReader.getNumHarddrives(HDinfo)
	return title
Пример #6
0
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())
Пример #7
0
def getComponentList(fname):
	components = []
	model = LogReader.getModel(fname).split(" ")[-1]
	cpus = LogReader.getProcInfo(fname)
	hdds = LogReader.getHarddrives(fname,True)
	ram = LogReader.getTotalRam(fname)
	ramAmt = "".join(ram[3].split(" ")).split(",")
	components.append(model)
	components.append(LogReader.getCtlr(fname,True))
	for k,v in cpus.items():
		for x in range(0,int(v)):
			components.append(k)
	for hd in hdds:
		for x in range(0,int(hd[-2])):
			ff = hd[3]
			if len(ff) > 3:
				ff = ff[:3]
			components.append("{} {}-{}".format(hd[1],LogReader.getHDSpeed(hd[-1]),ff))
	for r in ramAmt:
		rSplit = r.split("x")
		size = rSplit[0]
		amount = rSplit[1]
		for x in range(0,int(amount)):
			rString = "{}-{}".format(size,ram[1])
			components.append(rString)
			

  
	#Append a form factor to the model if we can get one off of a harddrive
	if len(hdds) > 0:
		ff = hdds[0][3]
		if len(ff) > 3:
			components[components.index(model)] = "{}-{}".format(model,ff[:3])

	for i in range(len(components)):
		components[i] = components[i].lower()
	return components
Пример #8
0
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())