soonmyeong2

make checking file for db data change

import hashlib
from firebase_admin import db
from firebase_admin import credentials
import firebase_admin
import csv
cred = credentials.Certificate('wello_firebase_SDKKey.json')
firebase_admin.initialize_app(cred, {'databaseURL': 'https://capstone-vip.firebaseio.com/'})
ref = db.reference()
policies = ref.get()
## compare dict
policy_dict = dict()
def policy_hash_writer(policies):
with open('./hash_policy.csv', 'w', encoding='utf-8', newline='') as csvfile:
wr = csv.writer(csvfile)
for policy in policies:
sha = hashlib.sha256()
sha.update(str(policy).encode('utf-8'))
wr.writerow([policy["Value"], sha.hexdigest()])
def policy_db_reader():
for policy in policies:
if policy["Value"] in policy_dict.keys():
sha = hashlib.sha256()
sha.update(str(policy).encode('utf-8'))
if policy_dict[policy["Value"]] != sha.hexdigest():
print("change contents : ", policy["Value"], ".", policy["Policy"])
else:
print("new policy : ", policy["Value"], ". ", policy["Policy"])
def policy_hash_reader():
with open('./hash_policy.csv', 'r', encoding='utf-8') as csvfile:
rdr = csv.reader(csvfile)
for r in rdr:
policy_dict[r[0]] = r[1]
#policy_hash_writer(policies)
policy_hash_reader()
policy_db_reader()
......@@ -5,14 +5,14 @@ from D_dayCalculator import D_day
import json
cred = credentials.Certificate('wello_firebase_SDKKey.json')
firebase_admin.initialize_app(cred, {'databaseURL': 'https://wello-pocliy-temp.firebaseio.com/'})
firebase_admin.initialize_app(cred, {'databaseURL': 'https://capstone-vip.firebaseio.com/'})
ref = db.reference()
policies = ref.get()
date = D_day("1970.01.01")
with open('view_count_raw.json', 'rt', encoding='utf-8') as json_file:
view_count = json.load(json_file)
#with open('view_count_raw.json', 'rt', encoding='utf-8') as json_file:
# view_count = json.load(json_file)
for policy in policies:
......
0,d24548533c984425a9a96cbd23e0085baed58a16d26d2764ee3e08f4ec9f2713
1,4f2e40e552527f48278fa2cdfadfa34e61c5a1672d82dc2ff42fcb4bff484cc2
2,7f41b893ec6ca567b928f9ba975c87e31db98a14fa6bc1c28431ab3a244cca43
3,fb6094dc6ba8c21846557664fda37a808f9877f35f301c444194b484e6cf38ae
4,121b23de7cf0d313077a208739b7a202ddfe6442c3f62dd2ed0cb475411c3bb8
5,26e05536f3fc6a844af4a746ecd070157180e4787fb122cf18b5dc8b91d2ff63
6,2809644d986b0226b080fdffbe7d3d1453095a12984101edbaefbf61821a8848
7,c7e3ac97575b1006424d0f2a391df327dc249067f0361d604355700bbe780102
8,3d7f2a439aa277c88101b08d2af865d6610f9791b614d9bbcce5a5f424736bb5
9,fba861e8ecc5f5411dec793409f8a98a96cbbb738fba74be397294e288dc7a4b
......@@ -14,6 +14,7 @@
<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">@drawable/background_splash</item>
<item name="android:scaleType">fitXY</item>
</style>
<style name="EditTheme" >
......