本文整理汇总了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:
示例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: