-
-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #642 from hackforla/PickleBaseFix
Pickle base fix
- Loading branch information
Showing
6 changed files
with
40 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,35 @@ | ||
import os | ||
from .query import query as query_pb | ||
from .populate import populate as populate_pb | ||
from .data_access import clear_data, set_ready, check_ready | ||
|
||
|
||
class PickleBase(object): | ||
def __init__(self): | ||
self.enabled = False | ||
self.enabled = int(os.environ.get('PICKLEBASE', 0)) == 1 | ||
self.ready = False | ||
|
||
def available(self): | ||
if not self.enabled: | ||
return False | ||
if self.ready: | ||
return True | ||
self.ready = check_ready() | ||
return self.ready | ||
|
||
def populate(self): | ||
populate_pb() | ||
try: | ||
clear_data() | ||
populate_pb() | ||
set_ready() | ||
print('PICKLEBASE IS READY') | ||
except Exception as e: | ||
self.enabled = False | ||
print('FAILED TO POPULATE PICKLEBASE') | ||
print(e) | ||
|
||
def query(self, table, fields, filters): | ||
return query_pb(table, fields, filters) | ||
|
||
|
||
pb = PickleBase() | ||
|
||
|
||
if int(os.environ.get('PICKLEBASE', 0)) == 1: | ||
print('PICKLEBASE ENABLED') | ||
try: | ||
pb.populate() | ||
pb.enabled = True | ||
except Exception as e: | ||
print('FAILED TO POPULATE PICKLEBASE') | ||
print(e) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters