Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 3
0
def default(argc):
		if argc.find(".txt") > 0:
			logFile = argc[0:argc.find(".txt")] + ".txt"
		else:
			logFile = argc + ".txt"
		if not AbsolutePath:
			logPath = LogReader.getLogPath(str(logFile))
		else:
			logPath = argc
		if logPath is not None:
			if LogReader.getProcInfo(logPath) is None or LogReader.getTotalRam(logPath) is None:
				print("Something went wrong with {}. Skipping".format(logPath))
			postItem(logPath)
		else:
			print("Could not find file {}".format(str(logFile)))
Ejemplo n.º 4
0
def getPrice(fname):
	components = getComponentList(fname)
	componentCounter = dict(Counter(components))
	price = 0
	db = sqlite3.connect(LogReader.getConfigValue("PriceDB"))
	cur = db.cursor()
	query = "SELECT * FROM prices"

	cur.execute(query)
	db.commit()
	rows = cur.fetchall()
	names = [desc[0] for desc in cur.description]
	nameIndex = names.index("name")
	priceIndex = names.index("price")
	for i in range(len(rows)):
		rName = rows[i][nameIndex]
		if isfloat(rName):
			rName = str(int(float(rows[i][nameIndex])))
		for component in components:
			if tryMatch(component,rName.lower()):
				componentCounter[component] -= 1
				price += float(rows[i][priceIndex])

	for k,v in componentCounter.items():
		if v > 0:
			print "Price for {} not found.".format(k)

	return price
Ejemplo n.º 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
Ejemplo n.º 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())
Ejemplo n.º 7
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")
Ejemplo n.º 8
0
def getSpecificPrice(name):
	db = sqlite3.connect(LogReader.getConfigValue("PriceDB"))
	cur = db.cursor()
	query = "SELECT * FROM prices"

	cur.execute(query)
	db.commit()
	rows = cur.fetchall()
	names = [desc[0] for desc in cur.description]
	nameIndex = names.index("name")
	score = [0,""]
	for row in rows:
		d = jwtools.stringScore(name,row[nameIndex])
		if d > score[0]:
			score[0] = d
			score[1] = row[nameIndex]

	print "Best match for {} : {} with {}".format(name,score[1],score[0])
Ejemplo n.º 9
0
def getConfig(model,varName=None):
	try:
		configFile = file(LogReader.getConfigValue("EbayConfig"),"r")
		cValues = jwjson.loadJSON(configFile.read())
		configFile.close()
		#if cfgOverride.has_key(varName):
		#	return cfgOverride[varName]
		if cValues.has_key(model):
			if varName is None:
				return cValues[model]
			if cValues[model].has_key(varName):
				print(cValues[model][varName])
				if type(cValues[model][varName]) is str or type(cValues[model][varName]) is unicode:
					
					if cValues[model][varName][:2] == "./":
						realpath = os.path.dirname(os.path.realpath(sys.argv[0]))
						
						return realpath + cValues[model][varName][1:]

				return cValues[model][varName]

		if cValues.has_key("default"):
			if varName is None:
				return cValues["default"]
			if cValues["default"].has_key(varName):
				if type(cValues["default"][varName]) is str or type(cValues["default"][varName]) is unicode:
					
					if cValues["default"][varName][:2] == "./":
						realpath = os.path.dirname(os.path.realpath(sys.argv[0]))
						return realpath + cValues["default"][varName][1:]

				return cValues["default"][varName]

		print("Warning: Could not find any config for {}".format(varName))
		return None

	except Exception as e:
		print("Warning: Could not load config file!")
		print(e)
		return None
Ejemplo n.º 10
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
Ejemplo n.º 11
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
Ejemplo n.º 12
0
if len(assets) <= 0:
	print("Scan or type the serial numbers now. Return a blank line when finished")
	while True:
		line = sys.stdin.readline();
		if line == '\n':
			break
		else:
			assets.add(line.rstrip() + ".txt");



workbook, ws = genXML(len(assets));

for x in assets:
	try:
		logpath = LogReader.getLogPath(x)

		if logpath is None:
			print("Error: {} not found.".format(x))
			continue
		
		addServer(ws,logpath, index);
		index += 1;	
		
	except Exception:
		print(traceback.print_exc());
		print("Failed at S/N:"+x)

getInfoFromXML()	
addInfoToXML(ws)
genSingleXML()
Ejemplo n.º 13
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())