fix/nonetype error?

This commit is contained in:
SouthFox 2022-11-08 23:12:17 +08:00
parent 42de925ed9
commit 57cadb2e11

View file

@ -1,6 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from types import NoneType
from mastodon import Mastodon from mastodon import Mastodon
from BDSM import db from BDSM import db
from BDSM.models import Other, Toot, Tag, Media, Emoji, Poll from BDSM.models import Other, Toot, Tag, Media, Emoji, Poll
@ -141,7 +140,7 @@ def toot_process(statuses, my_acct, duplicates_counter=0):
if not is_reblog: if not is_reblog:
data=Emoji.query.filter_by(shortcode=shortcode, acct=acct).first() data=Emoji.query.filter_by(shortcode=shortcode, acct=acct).first()
if data is None or NoneType: if data == None:
emoji_data = Emoji(shortcode=shortcode, emoji_data = Emoji(shortcode=shortcode,
acct=acct, acct=acct,
url=emoji['url'], url=emoji['url'],
@ -150,6 +149,9 @@ def toot_process(statuses, my_acct, duplicates_counter=0):
db.session.merge(emoji_data) db.session.merge(emoji_data)
# cur.execute('''INSERT INTO EMOJI (shortcode,url,static_url,count) \ # cur.execute('''INSERT INTO EMOJI (shortcode,url,static_url,count) \
# VALUES (?,?,?,?)''', (shortcode, emoji['url'], emoji['static_url'], count)) # VALUES (?,?,?,?)''', (shortcode, emoji['url'], emoji['static_url'], count))
else:
if data.count == None:
data.count = count
else: else:
data.count += count data.count += count
# cur.execute("UPDATE EMOJI SET count = ? WHERE shortcode = ?",(count, shortcode)) # cur.execute("UPDATE EMOJI SET count = ? WHERE shortcode = ?",(count, shortcode))