mirror of
https://github.com/barronwaffles/dwc_network_server_emulator.git
synced 2026-07-17 08:31:03 -05:00
[WIP] NAS: Moved action='count' in dlc
This commit is contained in:
parent
9148578223
commit
08a4697cf7
|
|
@ -252,25 +252,7 @@ class NasHTTPServerHandler(BaseHTTPServer.BaseHTTPRequestHandler):
|
|||
return
|
||||
|
||||
if action == "count":
|
||||
if post["gamecd"] in dlc.gamecodes_return_random_file:
|
||||
ret = "1"
|
||||
else:
|
||||
count = 0
|
||||
|
||||
if os.path.exists(dlcpath):
|
||||
count = len(os.listdir(dlcpath))
|
||||
|
||||
if os.path.isfile(dlcpath + "/_list.txt"):
|
||||
attr1 = post.get("attr1", None)
|
||||
attr2 = post.get("attr2", None)
|
||||
attr3 = post.get("attr3", None)
|
||||
|
||||
dlcfi = dlc.safeloadfi(dlcpath, "_list.txt")
|
||||
lst = dlc.filter_list(dlcfi,
|
||||
attr1, attr2, attr3)
|
||||
count = dlc.get_file_count(lst)
|
||||
|
||||
ret = "%d" % count
|
||||
ret = dlc.download_count(dlc_path, post)
|
||||
|
||||
if action == "list":
|
||||
num = post.get("num", None)
|
||||
|
|
|
|||
20
other/dlc.py
20
other/dlc.py
|
|
@ -141,3 +141,23 @@ def safeloadfi(dlc_path, name, mode='rb'):
|
|||
"""
|
||||
with open(os.path.join(dlc_path, name), mode) as f:
|
||||
return f.read()
|
||||
|
||||
|
||||
def download_count(dlc_path, post):
|
||||
"""Handle download count request."""
|
||||
if post["gamecd"] in gamecodes_return_random_file:
|
||||
return "1"
|
||||
elif os.path.exists(dlc_path):
|
||||
if os.path.isfile(os.path.join(dlc_path, "_list.txt")):
|
||||
attr1 = post.get("attr1", None)
|
||||
attr2 = post.get("attr2", None)
|
||||
attr3 = post.get("attr3", None)
|
||||
|
||||
dlc_file = safeloadfi(dlc_path, "_list.txt")
|
||||
ls = filter_list(dlc_file, attr1, attr2, attr3)
|
||||
count = get_file_count(ls)
|
||||
else:
|
||||
count = len(os.listdir(dlc_path))
|
||||
return "%d" % count
|
||||
else:
|
||||
return "0"
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user