当前位置: 首页>>代码示例>>Python>>正文


Python Adafruit_Thermal.write方法代码示例

本文整理汇总了Python中Adafruit_Thermal.write方法的典型用法代码示例。如果您正苦于以下问题:Python Adafruit_Thermal.write方法的具体用法?Python Adafruit_Thermal.write怎么用?Python Adafruit_Thermal.write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Adafruit_Thermal的用法示例。


在下文中一共展示了Adafruit_Thermal.write方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: genAndPrintKeys

# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import write [as 别名]
def genAndPrintKeys(curbtc, inputamt, numCopies, password, lcd):
	remPubKey = False
	remPrivKey = False

	#open serial number file which tracks the serial number
	snumfile = open('serialnumber.txt', 'r+')
	snum = snumfile.read()

	#open the printer itself
	printer = Adafruit_Thermal("/dev/ttyAMA0", 19200, timeout=5)


	#load a blank image of the paper wallet with no QR codes or keys on it which we will draw on
	finalImg = Image.open("btc-wallet-blank.bmp")
	lcd_display(lcd, "Generating", "address")
	#this actually generates the keys.  see the file genkeys.py or genkeys_forget.py
	import genkeys as btckeys

	btckeys.genKeys()

	if btckeys.keysAreValid == False:
		printer.write("Error: The generated keys (public/private) are not the correct length.  Please try again.")
		
	#import wallet_enc as WalletEnc
	#encrypt the keys if needed
	#if(password != ""):
	#	privkey = WalletEnc.pw_encode(btckeys.privkey, password)
	#else:
	privkey = btckeys.privkey
	
	
	rememberKeys = False
	sqlitePubKey = ""
	sqlitePrivKey = ""
	strToWrite = ""
	if remPubKey:
		strToWrite = "\nPublic Key: "+btckeys.pubkey
		sqlitePubKey = btckeys.pubkey
		rememberKeys = True

	if remPrivKey:
		strToWrite = strToWrite + "\nPrivate Key: "+privkey
		sqlitePrivKey = privkey
		rememberKeys = True


	if rememberKeys == True:
		#store it to the sqlite db
		con = None
		try:
			con = sqlite3.connect('/home/pi/build/Piper/keys.db3')
		        con.execute("INSERT INTO keys (serialnum, public, private) VALUES (?,?,?)", (snum, sqlitePubKey, sqlitePrivKey))
		except sqlite3.Error, e:
			print "Error %s:" % e.args[0]
			sys.exit(1)
		finally:
开发者ID:Chankster,项目名称:BitBox,代码行数:58,代码来源:piper.py

示例2: genAndPrintKeys

# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import write [as 别名]
def genAndPrintKeys(remPubKey, remPrivKey, numCopies, password):


	#open serial number file which tracks the serial number
	snumfile = open('serialnumber.txt', 'r+')
	snum = snumfile.read()

	#open the printer itself
	printer = Adafruit_Thermal("/dev/ttyAMA0", 19200, timeout=5)



	#this actually generates the keys.  see the file genkeys.py or genkeys_forget.py
	import genkeys as btckeys

	btckeys.genKeys()

	if btckeys.keysAreValid == False:
		printer.write("Error: The generated keys (public/private) are not the correct length.  Please try again.")
		
	import wallet_enc as WalletEnc
	#encrypt the keys if needed
	if(password != ""):
		privkey = WalletEnc.pw_encode(btckeys.pubkey, btckeys.privkey, password)
	else:
		privkey = btckeys.privkey
	
	
	rememberKeys = False
	sqlitePubKey = ""
	sqlitePrivKey = ""
	strToWrite = ""
	if remPubKey:
		strToWrite = "\nPublic Key: "+btckeys.pubkey
		sqlitePubKey = btckeys.pubkey
		rememberKeys = True

	if remPrivKey:
		strToWrite = strToWrite + "\nPrivate Key: "+privkey
		sqlitePrivKey = privkey
		rememberKeys = True


	if rememberKeys == True:
		#store it to the sqlite db
		con = None
		try:
			con = sqlite3.connect('/home/pi/Printer/keys.db3')
		        con.execute("INSERT INTO keys (serialnum, public, private) VALUES (?,?,?)", (snum, sqlitePubKey, sqlitePrivKey))
		except sqlite3.Error, e:
			print "Error %s:" % e.args[0]
			sys.exit(1)
		finally:
开发者ID:silky,项目名称:Piper,代码行数:55,代码来源:piper.py


注:本文中的Adafruit_Thermal.write方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。