Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

netfunnel -> already completed error #278

Merged
merged 16 commits into from
Dec 23, 2024
Merged
6 changes: 5 additions & 1 deletion SRT/netfunnel.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class NetFunnelHelper:

WAIT_STATUS_PASS = "200" # No need to wait
WAIT_STATUS_FAIL = "201" # Need to wait
ALREADY_COMPLETED = "502" # already completed(set-complete)

DEFAULT_HEADERS = {
"User-Agent": USER_AGENT,
Expand Down Expand Up @@ -161,7 +162,10 @@ def _set_complete(self, key: str):
raise SRTNetFunnelError(e) from e

netfunnel_resp = NetFunnelResponse.parse(resp.text)
if netfunnel_resp.get("status") != self.WAIT_STATUS_PASS:
if netfunnel_resp.get("status") not in [
self.WAIT_STATUS_PASS,
self.ALREADY_COMPLETED,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

]:
raise SRTNetFunnelError(f"Failed to complete NetFunnel: {netfunnel_resp}")

def _get_timestamp_for_netfunnel(self):
Expand Down
20 changes: 10 additions & 10 deletions SRT/passenger.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,22 +78,22 @@ def get_passenger_dict(
"totPrnb": Passenger.total_count(passengers),
"psgGridcnt": str(len(passengers)),
}
for _, passenger in enumerate(passengers):
code = passenger.type_code
data[f"psgTpCd{code}"] = passenger.type_code
data[f"psgInfoPerPrnb{code}"] = str(passenger.count)
for idx, passenger in enumerate(passengers):
psgidx = idx + 1
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

감사합니다. 이 동작이 맞는지 한 번 다시 확인해볼게요.

data[f"psgTpCd{psgidx}"] = passenger.type_code
data[f"psgInfoPerPrnb{psgidx}"] = str(passenger.count)
# seat location ('000': 기본, '012': 창측, '013': 복도측)
data[f"locSeatAttCd{code}"] = WINDOW_SEAT[window_seat]
data[f"locSeatAttCd{psgidx}"] = WINDOW_SEAT[window_seat]
# seat requirement ('015': 일반, '021': 휠체어)
# TODO: 선택 가능하게
data[f"rqSeatAttCd{code}"] = "015"
data[f"rqSeatAttCd{psgidx}"] = "015"
# seat direction ('009': 정방향)
data[f"dirSeatAttCd{code}"] = "009"
data[f"dirSeatAttCd{psgidx}"] = "009"

data[f"smkSeatAttCd{code}"] = "000"
data[f"etcSeatAttCd{code}"] = "000"
data[f"smkSeatAttCd{psgidx}"] = "000"
data[f"etcSeatAttCd{psgidx}"] = "000"
# seat type: ('1': 일반실, '2': 특실)
data[f"psrmClCd{code}"] = "2" if special_seat else "1"
data[f"psrmClCd{psgidx}"] = "2" if special_seat else "1"

return data

Expand Down
4 changes: 2 additions & 2 deletions SRT/srt.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,8 @@ def _reserve(
"arvTm1": train.arr_time, # 도착일자1 (열차 목록 값)
"totPrnb": passengersCount, # 승차인원
"psgGridcnt": passengersCount, # 승차인원
"psgTpCd1": passengersCount, # 승차인원
"psgInfoPerPrnb1": passengersCount, # 승차인원
"psgTpCd1": "0", # 승객종류1 passenger.code (psgTpCd1~5, 1~5)
"psgInfoPerPrnb1": "0", # 승객종류1 인원수 (psgInfoPerPrnb1~5)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

passenger 객체에서 만들어줘서 넘어오니 이 부분은 그냥 없애도 될 것 같습니다 (totPrnb, psgGridcnt, psgTpCd1, psgInfoPerPrnb1, 등등)

"trnNo1": "%05d" % int(train.train_number), # 열차번호1 (열차 목록 값)
"runDt1": train.dep_date, # 운행일자1 (열차 목록 값)
"psrmClCd1": "2" if is_special_seat is True else "1",
Expand Down
Loading