mirror of
https://git.sdf.org/tamservo/robottas.git
synced 2025-11-08 07:03:47 -05:00
Added binger. Fixed issue with delta string.
This commit is contained in:
26
binger.py
Executable file
26
binger.py
Executable file
@@ -0,0 +1,26 @@
|
||||
import glob
|
||||
from random import randrange
|
||||
import sqlite3
|
||||
|
||||
BING_IMGS_PATH = "bing/*"
|
||||
DB = "bing.db"
|
||||
|
||||
def get_image_count():
|
||||
# Choose a random image
|
||||
bing_files = glob.glob(BING_IMGS_PATH)
|
||||
image_idx = randrange(len(bing_files))
|
||||
image = bing_files[image_idx]
|
||||
|
||||
# Get the latest count and increment
|
||||
con = sqlite3.connect(DB)
|
||||
cur = con.cursor()
|
||||
cur.execute("UPDATE BING_COUNT SET COUNT = COUNT + 1")
|
||||
con.commit()
|
||||
result = cur.execute("SELECT COUNT FROM BING_COUNT")
|
||||
count = result.fetchone()
|
||||
count = count[0]
|
||||
|
||||
cur.close()
|
||||
con.close()
|
||||
|
||||
return(image, count)
|
||||
Reference in New Issue
Block a user