From 4b8aab1e63711202f2e4ffd9f207614f51b413ef Mon Sep 17 00:00:00 2001 From: Abbas Tawfiq Ali Abdulrab <71519@omantel.om> Date: Sun, 28 Apr 2024 14:32:04 +0400 Subject: [PATCH 01/12] save --- .idea/.gitignore | 3 + .idea/.name | 1 + .idea/PackageMeasurementConversionAPI.iml | 10 ++ .../inspectionProfiles/profiles_settings.xml | 6 ++ .idea/misc.xml | 7 ++ .idea/modules.xml | 8 ++ .idea/vcs.xml | 6 ++ main_app - Copy.py | 79 ++++++++++++++++ main_app.py | 41 +++++++++ .../sequence_controller.cpython-312.pyc | Bin 0 -> 1859 bytes src/controller/sequence_controller - Copy.py | 80 ++++++++++++++++ src/controller/sequence_controller.py | 40 ++++++++ src/data/store_sequence.json | 5 + .../__pycache__/sequence.cpython-312.pyc | Bin 0 -> 4874 bytes src/models/__pycache__/string.cpython-312.pyc | Bin 0 -> 1052 bytes src/models/sequence.py | 87 ++++++++++++++++++ src/models/string.py | 17 ++++ src/services/JSONdataformat.py | 13 +++ src/services/SQLDataFormat.py | 11 +++ .../JSONdataformat.cpython-312.pyc | Bin 0 -> 813 bytes .../__pycache__/SQLDataFormat.cpython-312.pyc | Bin 0 -> 760 bytes .../__pycache__/dataformat.cpython-312.pyc | Bin 0 -> 890 bytes .../sequence_history.cpython-312.pyc | Bin 0 -> 3672 bytes .../sequence_service.cpython-312.pyc | Bin 0 -> 1820 bytes src/services/dataformat.py | 15 +++ src/services/sequence_history.py | 66 +++++++++++++ src/services/sequence_service.py | 32 +++++++ 27 files changed, 527 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/.name create mode 100644 .idea/PackageMeasurementConversionAPI.iml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 main_app - Copy.py create mode 100644 main_app.py create mode 100644 src/controller/__pycache__/sequence_controller.cpython-312.pyc create mode 100644 src/controller/sequence_controller - Copy.py create mode 100644 src/controller/sequence_controller.py create mode 100644 src/data/store_sequence.json create mode 100644 src/models/__pycache__/sequence.cpython-312.pyc create mode 100644 src/models/__pycache__/string.cpython-312.pyc create mode 100644 src/models/sequence.py create mode 100644 src/models/string.py create mode 100644 src/services/JSONdataformat.py create mode 100644 src/services/SQLDataFormat.py create mode 100644 src/services/__pycache__/JSONdataformat.cpython-312.pyc create mode 100644 src/services/__pycache__/SQLDataFormat.cpython-312.pyc create mode 100644 src/services/__pycache__/dataformat.cpython-312.pyc create mode 100644 src/services/__pycache__/sequence_history.cpython-312.pyc create mode 100644 src/services/__pycache__/sequence_service.cpython-312.pyc create mode 100644 src/services/dataformat.py create mode 100644 src/services/sequence_history.py create mode 100644 src/services/sequence_service.py diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..b5955c9 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +sequence.py \ No newline at end of file diff --git a/.idea/PackageMeasurementConversionAPI.iml b/.idea/PackageMeasurementConversionAPI.iml new file mode 100644 index 0000000..2c80e12 --- /dev/null +++ b/.idea/PackageMeasurementConversionAPI.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..1b435f8 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..e89135d --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/main_app - Copy.py b/main_app - Copy.py new file mode 100644 index 0000000..b1b6fd3 --- /dev/null +++ b/main_app - Copy.py @@ -0,0 +1,79 @@ +def process_string_to_list(input_string): + """Convert the input string to a list of integers based on character positions, + where 'a' is 1, 'z' is 26, and '_' is 0.""" + converted_list = [] + i = 0 + n = len(input_string) + while i < n: + if 'a' <= input_string[i] <= 'z': + num_chars_to_consider = ord(input_string[i]) - ord('a') + 1 + converted_list.append(num_chars_to_consider) + i += 1 + elif input_string[i] == '_': + converted_list.append(0) + i += 1 + return converted_list + +def combine_consecutive_26s(converted_list): + """Combine all consecutive 26s in the list with the next non-26 value.""" + combined_list = [] + i = 0 + while i < len(converted_list): + if converted_list[i] == 26: + sum_26 = 0 + while i < len(converted_list) and converted_list[i] == 26: + sum_26 += converted_list[i] + i += 1 + if i < len(converted_list): + sum_26 += converted_list[i] + combined_list.append(sum_26) + i += 1 # Increment to skip the next element already added to sum_26 + else: + combined_list.append(converted_list[i]) + i += 1 + return combined_list + +def process_list(input_string): + """Process the input string to combine consecutive 26s with the next value.""" + converted_list = process_string_to_list(input_string) + combined_list = combine_consecutive_26s(converted_list) + return combined_list + +def create_result(input_string): + if input_string.startswith('_'): + return [0] + + combined_list = process_list(input_string) + results = [] + i = 0 + + while i < len(combined_list): + count = combined_list[i] if i < len(combined_list) else 0 + sum_sequence = 0 + if count > 0 and i + 1 < len(combined_list): + + sum_sequence = sum(combined_list[i + 1:i + 1 + count]) + + results.append(sum_sequence) + i += count + 1 + + if i >= len(combined_list) and (count == 0 or i + 1 >= len(combined_list)): + break + + return results + + +# Test the full processing function +print(create_result('abbcc')) +print(create_result('dz_a_aazzaaa')) +print(create_result('a_')) +print(create_result('abcdabcdab')) +print(create_result('abcdabcdab_')) +print(create_result('zdaaaaaaaabaaaaaaaabaaaaaaaabbaa')) +print(create_result('zza_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_')) +print(create_result('za_a_a_a_a_a_a_a_a_a_a_a_a_azaaa')) +print(create_result('_a')) +print(create_result('_')) +print(create_result('_ad')) +print(create_result('_zzzb')) +print(create_result('__')) diff --git a/main_app.py b/main_app.py new file mode 100644 index 0000000..8333030 --- /dev/null +++ b/main_app.py @@ -0,0 +1,41 @@ +import cherrypy +import os + + +from src.controller.sequence_controller import SequenceAPI + + +class Root(object): + @cherrypy.expose() + def index(self): + """ + This function is going to return index.html files present in the static directory. + We don't need to implement it since it configured and cherrypy is going to handle it. + """ + pass + + +cherrypy.config.update({'server.socket_host': '0.0.0.0', 'server.socket_port': 8080}) + +# Mount the ContactsAPI application +cherrypy.tree.mount(SequenceAPI(), '/api/sequence', { + '/': { + 'request.dispatch': cherrypy.dispatch.MethodDispatcher(), # Use method-based dispatching + 'tools.sessions.on': False, + 'tools.response_headers.on': True, + 'tools.response_headers.headers': [('Content-Type', 'text/plain')] + } +}) + +cherrypy.tree.mount(Root(), '/', { + '/': { + 'tools.staticdir.root': os.path.abspath(os.path.dirname(__file__)), + 'tools.staticdir.on': True, + 'tools.staticdir.dir': 'static', + 'tools.staticdir.index': 'index.html', + } +}) + +# Start the CherryPy server +cherrypy.engine.start() +cherrypy.engine.block() diff --git a/src/controller/__pycache__/sequence_controller.cpython-312.pyc b/src/controller/__pycache__/sequence_controller.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0063fb06571374781854c07a13ac95a791731caa GIT binary patch literal 1859 zcmZ`(O>7%Q6rSDndUq55C8=;IPNAt2v9xtbr8X%oMQun!5wsOX7YXL@{`SqA zZ{B=we~!ny5UjOqZt8~!Lcek+TykLSR=~K6EMy5bD)?F`2%aw%L{Ccv3AAWOs&YXV zc#dR8t4cxf?1-&awSwl^vfWkfE_4e>M3cyh-a(dvW2=&XRw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%vOLY)Ck{}41D7lGJo2YveX}_WD6Ljhc VI`IS@dlu~%(#yktB2Zqbe*n;3-3I^w literal 0 HcmV?d00001 diff --git a/src/controller/sequence_controller - Copy.py b/src/controller/sequence_controller - Copy.py new file mode 100644 index 0000000..d332275 --- /dev/null +++ b/src/controller/sequence_controller - Copy.py @@ -0,0 +1,80 @@ +def process_string_to_list(input_string): + """Convert the input string to a list of integers based on character positions, + where 'a' is 1, 'z' is 26, and '_' is 0.""" + converted_list = [] + i = 0 + n = len(input_string) + while i < n: + if 'a' <= input_string[i] <= 'z': + num_chars_to_consider = ord(input_string[i]) - ord('a') + 1 + converted_list.append(num_chars_to_consider) + i += 1 + elif input_string[i] == '_': + converted_list.append(0) + i += 1 + return converted_list + + +def combine_consecutive_26s(converted_list): + """Combine all consecutive 26s in the list with the next non-26 value.""" + combined_list = [] + i = 0 + while i < len(converted_list): + if converted_list[i] == 26: + sum_26 = 0 + while i < len(converted_list) and converted_list[i] == 26: + sum_26 += converted_list[i] + i += 1 + if i < len(converted_list): + sum_26 += converted_list[i] + combined_list.append(sum_26) + i += 1 # Increment to skip the next element already added to sum_26 + else: + combined_list.append(converted_list[i]) + i += 1 + return combined_list + +def process_list(input_string): + """Process the input string to combine consecutive 26s with the next value.""" + converted_list = process_string_to_list(input_string) + combined_list = combine_consecutive_26s(converted_list) + return combined_list + +def create_result(input_string): + if input_string.startswith('_'): + return [0] + + combined_list = process_list(input_string) + results = [] + i = 0 + + while i < len(combined_list): + count = combined_list[i] if i < len(combined_list) else 0 + sum_sequence = 0 + if count > 0 and i + 1 < len(combined_list): + + sum_sequence = sum(combined_list[i + 1:i + 1 + count]) + + results.append(sum_sequence) + i += count + 1 + + if i >= len(combined_list) and (count == 0 or i + 1 >= len(combined_list)): + break + + return results + + +# Test the full processing function +print(create_result('abbcc')) +print(create_result('dz_a_aazzaaa')) +print(create_result('a_')) +print(create_result('abcdabcdab')) +print(create_result('abcdabcdab_')) +print(create_result('zdaaaaaaaabaaaaaaaabaaaaaaaabbaa')) +print(create_result('zza_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_')) +print(create_result('za_a_a_a_a_a_a_a_a_a_a_a_a_azaaa')) +print(create_result('_a')) +print(create_result('_')) +print(create_result('_ad')) +print(create_result('_zzzb')) +print(create_result('__')) diff --git a/src/controller/sequence_controller.py b/src/controller/sequence_controller.py new file mode 100644 index 0000000..8ee5ff1 --- /dev/null +++ b/src/controller/sequence_controller.py @@ -0,0 +1,40 @@ +import cherrypy +import traceback +import json +import os + +from src.models.string import String +from src.services.sequence_service import SequenceService +from src.services.sequence_history import FileHandler +from src.models.sequence import StringProcessor + + +class SequenceAPI(object): + exposed = True + + @cherrypy.tools.json_out() + def GET(self, input_string: str = ""): + res_msg = {"status": "FAIL", "data": []} + file_handler = FileHandler(storage_format='json') + sequence = SequenceService() + try: + if input_string: + string_instance = String(input_string) + processor = StringProcessor(string_instance) + processed_results = processor.create_result() + + res_msg = {"status": "SUCCESS", "data": processed_results} + sequence.process_and_store_string(input_string) + + else: + file_data = file_handler.open_write_file(state='r') + res_msg = {"status": "SUCCESS", "data": file_data} + except Exception as e: + print(traceback.format_exc(e)) + res_msg = {"status": "fail", "err_msg": "invalid sequence", "result": []} + #res_msg["data"] = str(e) + + return res_msg + + + diff --git a/src/data/store_sequence.json b/src/data/store_sequence.json new file mode 100644 index 0000000..85c8e28 --- /dev/null +++ b/src/data/store_sequence.json @@ -0,0 +1,5 @@ +{"input_string": [52], "input_time": "2024-04-28 14:24:56"} +{"input_string": [52], "input_time": "2024-04-28 14:25:37"} +{"input_string": [52], "input_time": "2024-04-28 14:26:12"} +{"input_string": "haitham", "input_time": "2024-04-28 14:28:31"} +{"input_string": "za_a_a_a_a_a_a_a_a_a_a_a_a_azaaa", "input_time": "2024-04-28 14:28:54"} diff --git a/src/models/__pycache__/sequence.cpython-312.pyc b/src/models/__pycache__/sequence.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000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+wCjz-s_Ln9KuH^4J!bIZr~ADXXdUWJ5{v^_Vxq6?arYL=vCFGrTA=^jRNlVIb(i z4y*03q}U8Q-Pn#qxFIES-z7d#j5op@_A(4onM&0XFYDa-M|my$Xa&X z*UpN+ zMzIrg5*5FqL86fpgGrQBU!X0tg&&3KdNwS-({^78!^yBtRYi1-?jUT!(FJW#cw2Zk zzO8)MrVq85eQoCb!htq_s8#p1>fZg@f%bg6@U=X-r%sA#){H!@L+Av)Z6{;4jmy$) z5nr_JH(jTdS~wNqWr8aRJ0OC^S8|241azVage^Fhm|`5~nR0WOSCpyLo9y^v@(^Q5 qBWa0Fv;9^dq#Zou*U&)!5M4(2nPZH7hVd_O{a3!orj7wYg#86gg52N$ literal 0 HcmV?d00001 diff --git a/src/models/sequence.py b/src/models/sequence.py new file mode 100644 index 0000000..599079e --- /dev/null +++ b/src/models/sequence.py @@ -0,0 +1,87 @@ +from src.models.string import String + + +class StringProcessor: + def __init__(self, string_instance): + self.input_string = string_instance.get_string() + self.results = [] + self.converted_list = [] + self.combined_list = [] + + def process_string_to_list(self): + """Convert the input string to a list of integers based on character positions, + where 'a' is 1, 'z' is 26, and '_' is 0.""" + for char in self.input_string: + if 'a' <= char <= 'z': + num_chars_to_consider = ord(char) - ord('a') + 1 + self.append_converted_list(num_chars_to_consider) + elif char == '_': + self.append_converted_list(0) + + def append_converted_list(self, value): + self.converted_list.append(value) + return self.converted_list + + def append_combined_list(self, num): + self.combined_list.append(num) + return self.combined_list + + def append_result(self, seq): + self.results.append(seq) + return self.results + + def handle_z_case(self): + """Combine all consecutive 26s in the list with the next non-26 value.""" + i = 0 + while i < len(self.converted_list): + if self.converted_list[i] == 26: + sum_26 = 0 + while i < len(self.converted_list) and self.converted_list[i] == 26: + sum_26 += self.converted_list[i] + i += 1 + if i < len(self.converted_list): + sum_26 += self.converted_list[i] + self.append_combined_list(sum_26) + i += 1 + else: + self.append_combined_list(self.converted_list[i]) + i += 1 + return self.combined_list + + def create_result(self): + """Process the input string to combine consecutive 26s with the next value and calculate sums.""" + if self.input_string.startswith('_'): + return [0] + + self.results = [] + converted_list = self.process_string_to_list() + combined_list = self.handle_z_case() + i = 0 + + while i < len(combined_list): + count = combined_list[i] if i < len(combined_list) else 0 + sum_sequence = 0 + if count > 0 and i + 1 < len(combined_list): + sum_sequence = sum(combined_list[i + 1:i + 1 + count]) + self.append_result(sum_sequence) + i += count + 1 + + if i >= len(combined_list) and (count == 0 or i + 1 >= len(combined_list)): + break + + return self.results + + +# Example usage +if __name__ == "__main__": + test_strings = [ + 'abbcc', 'dz_a_aazzaaa', 'a_', 'abcdabcdab', 'abcdabcdab_', + 'zdaaaaaaaabaaaaaaaabaaaaaaaabbaa', + 'zza_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_', + 'za_a_a_a_a_a_a_a_a_a_a_a_a_azaaa', '_a', '_', '_ad', '_zzzb', '__' + ] + + for test_string in test_strings: + processor = StringProcessor(test_string) + result = processor.create_result() + print(f"Input: {test_string} -> Got: {result}") diff --git a/src/models/string.py b/src/models/string.py new file mode 100644 index 0000000..e4cea97 --- /dev/null +++ b/src/models/string.py @@ -0,0 +1,17 @@ +import time +from datetime import datetime + + +class String: + def __init__(self, input_string): + self.input_string = input_string + + def get_string(self): + return self.input_string + + def epoch_time(self): + stamp = time.time() # Get current epoch time in seconds + # Convert epoch time to a datetime object and format it + date_time = datetime.fromtimestamp(stamp).strftime('%Y-%m-%d %H:%M:%S') + + return date_time diff --git a/src/services/JSONdataformat.py b/src/services/JSONdataformat.py new file mode 100644 index 0000000..449f54c --- /dev/null +++ b/src/services/JSONdataformat.py @@ -0,0 +1,13 @@ +import json + +from src.services.dataformat import DataFormat +from src.models.string import String + + +class JSONDataFormat(DataFormat): + def format(self, input_string): + return json.dumps({ + "input_string": input_string, + "input_time": String.epoch_time(self) + }) + "\n" + diff --git a/src/services/SQLDataFormat.py b/src/services/SQLDataFormat.py new file mode 100644 index 0000000..66aa77f --- /dev/null +++ b/src/services/SQLDataFormat.py @@ -0,0 +1,11 @@ +import sqlite3 + +from src.services.dataformat import DataFormat + + +class SQLDataFormat(DataFormat): + def __func(self): + pass + + def format(self, input_string): + self.__func() \ No newline at end of file diff --git a/src/services/__pycache__/JSONdataformat.cpython-312.pyc b/src/services/__pycache__/JSONdataformat.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f812714f6ac9b2aa07e104cf0a403bb2315dbf69 GIT binary patch literal 813 zcmZ8eON-M`6h1evsp&jAl|iX4x^Q6_rchMGVGv}BqF@~;B7|TF$?e#hN4+;0XqknJ zZd~cE8-IW@KgE@}P~x}}7w$Sl5xVl+q;=E-Iggz0yXW<8Wkm;+onKqss|4Vy2o|Ew zoopMO33%WUA538-p9GRA5#h_e94MwjK!Q8qDP!rx=J_D0UPN&( zpfjQyN~-jE6sD?|1Ov_#UUWQ6I?V{ug@OsZd(sIW!$>nyw<#7 zwIVkOXc%*A&vBnR`}96_c*3aow;P2Ai0nn-t-ZSzXRd|BgPu#dC3fWDuDkiJ8-ro0 z74B%`-}N<$-+2pHu!ZMvymt2G=*8&M#mmRF`p4Sl``YH4)`wd2M3pb-8OW9LRD;#( z$&y^DPC-6X&5(xIRnn4ehfY9kJJoGFh`huX{<3X9OB}z*unJ<|0$WGJ)`Sv^&(#t- zT&OW*lA=}%j7S?AE2Bxz;fRgJh>g?nm^gX5F0xpa`n*xxBj0#YU;`1SMQ5d*qP?5! hJSN1Ic@5Q6CWL&3@;7LFflEI$l~iAuKLJh7{SEbbzbya& literal 0 HcmV?d00001 diff --git a/src/services/__pycache__/SQLDataFormat.cpython-312.pyc b/src/services/__pycache__/SQLDataFormat.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..10d342143a277aed354a7c4df53eb8c2b996f7dc GIT binary patch literal 760 zcmZ8f&ui2`6n>LmU3WLdL)m&<&`U0XA|i?i(o#`$sfZpzUQ~+KOpfa9=wUsOHaO+*#)OSBVlt0%)~&nYSXhC_vMRc|CLx>Ta_Zy*6K>saLy*@fS#5T*;J8qeEE9! ze)viWslvNEcXsZDdqrH$L|&@!Ad25chvK=2R3!!Fc8mN3m1&VbI(QN)8HafBB#ng% z*SheJ>c-)GTIKP(t@RU~-9T$a^E-vFyABq ziuh$)e9ca~d4{}($IUR!kE)WZQl|N#B9HM{()%{fw0nT7&FU;E)BvGt_S4|Q;G-*t z7*9OA>2aP%Gr@V&=X_QqRYrWs`EeCx`b2J`R$eFQ5zy7nR?-AIaF8g<&*8VhY`1lo zJ<>wb;4^Qi<18)3?PeRt?ytt~C;0Q|E+x%NS6p|w>^;zZJ(MGq&>+<|!Y`9C_6;_F Rfd9v_+34))U%;(%{Re$vt~vk! literal 0 HcmV?d00001 diff --git a/src/services/__pycache__/dataformat.cpython-312.pyc b/src/services/__pycache__/dataformat.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3303097e04fe5805634f28abd5a4467c7dc84b6d GIT binary patch literal 890 zcmY*X&ubGw6rS1LtT85)TERm>hSp0U1bPrrM5rl>g0YY)vMdbK*=e(w-HkK5l>`qx zMDW;K{)W;&#j_xL5Mjme!d1*}fWWnVApF8PBFD7br1=s~!^`ed zrNQDDHP|y)h@JO35Byg~Y2)A9xVv%R-%4Z_sW>(MwvcbdzIvgA$+SXSCy5UrGECyl z?PtEx(uc%@P%7giM@i8hj`Aw!VH~EMk5~TPOnYI(XJAkqlCQVdJ~>~it269cE*66d zo?tQ_1QVzEq#`^{{8PnI$kzB46}^n&Itt7$D7A|S#Z~ysDu@aBY0=91 zsY~3OXMh?rdx6S4jP5oo`4!HCL;{~JcBRINOPZqO|1{^-hh=w<^eu?P`zyFkZA$5x XWmD%*jnF&4T$eVER(=!s6sSqlCT2{R5BUK+-_O&lDhT579Ql+X7`xYgYXw#RTJL6vz?L%*r zGxz7*bI(2JeCJ&MwY@!npq=Q8&HmPp&_CFq*7#~?v)S)_RGA;tU5<(!ae%W)CkH*AoM za8}2MQx}utk|~`rNJcVYCeSk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k45nWAXsylesGQTW3rI}gewXGn8oqMjHK74Z*tLZ zSQ*KOt~A%oI3_G_=DksTDVJQAxGk&mEaOmb9tXlFUu%6kl-QNqb{RPi z!!M9sU!9`PAVL^n*sz~E_fTc~`*)M;JTIK*)`K45=z6CYx*J_>!f9?}Pe|x<_Oo4) zAYpaiav9X(O$ZsQ2cE*Q+EX~jegZXK<<2vGXA4KuD$gWsW2Y(xXmb(( literal 0 HcmV?d00001 diff --git a/src/services/__pycache__/sequence_service.cpython-312.pyc b/src/services/__pycache__/sequence_service.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b3eae77e0c9a7658fb6a3f1e5a8f6fd28472bc55 GIT binary patch literal 1820 zcmZ`(L2nyH6rNe{uGjY3A!(r5$Zc29mTU>8Q57LVK+vLu0u2#?LoG|Am1o@8v3Jv% zb&)Nn${`2;gH)=JB2HAvp+}CnbFoP(r>o|~iCd6CNIfyLyN*ntBkj!FH}Ac9@0)Ml zFX?m=@UeF}SNcl^;5YFz7-}T+f8@e8zyQN4sKGphLYAshEtZc3a;z%Xl)M6g1Qr37 zw*XdlrO-RCk~mh^rU0Nh2@n;>_q1IY?P)lXPY|v0dUVpzLJ|Y30*{nW<#q0z#z~TT z3~-9*kHHV}zygAX-q5Y|@50}LzPjSkvU871BcZfR-6CPkrCgO-C|Aknwu7sL7KaYx zxrd`a$=7W_KptX{m#~cC7R<-6v<32VBW5W)D!E@LPLZq-`k-7S#eu5`5R1P4)gX)) z)e1lh?!iIEEr3q-4PZ%2PoSS+o=fd}1eIJ`vpq|q3XkCHC7v%@4HLE`UuL9QqT<$= zIMy^@-n}(f_>K|E3h&R%&U{e#%q`Yy#PL{R*)Fc}hXZoGE!TO#Ez7R+>GJIY zqs0Pu6g4m|ghio9lUr~28bW2K>><>gI8$?OuoD-VjPPj_yvV-&^x!DZLAfm2r$l!-ROTqZh^{xtwS~yZRjTwE2;nL zTBrB2p}Zne`hUC>4ELk~&mm~ZEu|!_04vtSNi!PX+G~WFwqur^^}1)WfSA+fdPqpV zRrbs}<773@Fm;+cVQ%kIZse^Jldtuv$8x8keP|0hVB52Og?Y9|tT+|uQ314{E>gmE zDD3Tbh9@Ova=n{I8njm#h!7kYh3FYvt47hXUunv`JW31#ux1j-%X@@ zn$gvao@RA5>!*kND;>=`)NUV*m^-=7$n}nPoeFv{@!la5}}%l z>->cxUq|SE-L8f^G{b%91wK6ifq#Gi6|W_j1T;*5vIY7QR2E@h%_uXWr7#j_)a}$nUjNgUH2Cd4ze1Dvd;UpN8c2M3akUHUTX6pv>(%VxlZ&;CK~oh3_^GeE+2#Uj=}8T>KL5) z1Mul&8pwLP`D@I0e*Wsy(&71!I`a6@n7R4okzw_Wn_c7P{)Y#~*IoII&BgZJ=W?Q> dU)qU3YILSP**Er6o#a=~ Date: Mon, 29 Apr 2024 11:52:11 +0400 Subject: [PATCH 02/12] refactoring and adjusting --- cherrypy.log | 105 ++++++++++++++++++ main_app - Copy.py | 79 ------------- main_app.py | 15 ++- src/__init__.py | 0 src/__pycache__/__init__.cpython-312.pyc | Bin 0 -> 169 bytes src/abstraction/__init__.py | 0 .../__pycache__/__init__.cpython-312.pyc | Bin 0 -> 181 bytes .../__pycache__/dataformat.cpython-312.pyc | Bin 890 -> 893 bytes src/{services => abstraction}/dataformat.py | 0 src/controller/__init__.py | 0 .../__pycache__/__init__.cpython-312.pyc | Bin 0 -> 180 bytes .../sequence_controller.cpython-312.pyc | Bin 1859 -> 2072 bytes src/controller/sequence_controller - Copy.py | 80 ------------- src/controller/sequence_controller.py | 23 ++-- src/data/sequence_history.db | Bin 0 -> 12288 bytes src/data/store_sequence.db | 22 ++++ src/data/store_sequence.json | 5 - src/deserializers/__init__.py | 0 src/models/__init__.py | 0 .../__pycache__/__init__.cpython-312.pyc | Bin 0 -> 176 bytes .../__pycache__/sequence.cpython-312.pyc | Bin 4874 -> 1078 bytes .../sequence_history.cpython-312.pyc | Bin 0 -> 2303 bytes src/models/__pycache__/string.cpython-312.pyc | Bin 1052 -> 0 bytes src/models/sequence.py | 97 +++------------- src/models/sequence_history.py | 37 ++++++ src/models/string.py | 17 --- src/serializers/JSONdataformat.py | 13 +++ src/serializers/SQLDataFormat.py | 29 +++++ src/serializers/__init__.py | 0 .../JSONdataformat.cpython-312.pyc | Bin 0 -> 867 bytes .../__pycache__/SQLDataFormat.cpython-312.pyc | Bin 0 -> 1988 bytes .../__pycache__/__init__.cpython-312.pyc | Bin 0 -> 181 bytes src/services/JSONdataformat.py | 13 --- src/services/SQLDataFormat.py | 11 -- src/services/__init__.py | 0 .../JSONdataformat.cpython-312.pyc | Bin 813 -> 0 bytes .../__pycache__/SQLDataFormat.cpython-312.pyc | Bin 760 -> 0 bytes .../__pycache__/__init__.cpython-312.pyc | Bin 0 -> 178 bytes .../sequence_history.cpython-312.pyc | Bin 3672 -> 0 bytes .../sequence_processor.cpython-312.pyc | Bin 0 -> 4929 bytes .../sequence_service.cpython-312.pyc | Bin 1820 -> 1822 bytes src/services/sequence_processor.py | 87 +++++++++++++++ src/services/sequence_service.py | 16 +-- .../File_Handler.py} | 39 ++----- src/utils/__init__.py | 0 .../__pycache__/File_Handler.cpython-312.pyc | Bin 0 -> 2552 bytes .../__pycache__/__init__.cpython-312.pyc | Bin 0 -> 175 bytes 47 files changed, 348 insertions(+), 340 deletions(-) create mode 100644 cherrypy.log delete mode 100644 main_app - Copy.py create mode 100644 src/__init__.py create mode 100644 src/__pycache__/__init__.cpython-312.pyc create mode 100644 src/abstraction/__init__.py create mode 100644 src/abstraction/__pycache__/__init__.cpython-312.pyc rename src/{services => abstraction}/__pycache__/dataformat.cpython-312.pyc (83%) rename src/{services => abstraction}/dataformat.py (100%) create mode 100644 src/controller/__init__.py create mode 100644 src/controller/__pycache__/__init__.cpython-312.pyc delete mode 100644 src/controller/sequence_controller - Copy.py create mode 100644 src/data/sequence_history.db create mode 100644 src/data/store_sequence.db delete mode 100644 src/data/store_sequence.json create mode 100644 src/deserializers/__init__.py create mode 100644 src/models/__init__.py create mode 100644 src/models/__pycache__/__init__.cpython-312.pyc create mode 100644 src/models/__pycache__/sequence_history.cpython-312.pyc delete mode 100644 src/models/__pycache__/string.cpython-312.pyc create mode 100644 src/models/sequence_history.py delete mode 100644 src/models/string.py create mode 100644 src/serializers/JSONdataformat.py create mode 100644 src/serializers/SQLDataFormat.py create mode 100644 src/serializers/__init__.py create mode 100644 src/serializers/__pycache__/JSONdataformat.cpython-312.pyc create mode 100644 src/serializers/__pycache__/SQLDataFormat.cpython-312.pyc create mode 100644 src/serializers/__pycache__/__init__.cpython-312.pyc delete mode 100644 src/services/JSONdataformat.py delete mode 100644 src/services/SQLDataFormat.py create mode 100644 src/services/__init__.py delete mode 100644 src/services/__pycache__/JSONdataformat.cpython-312.pyc delete mode 100644 src/services/__pycache__/SQLDataFormat.cpython-312.pyc create mode 100644 src/services/__pycache__/__init__.cpython-312.pyc delete mode 100644 src/services/__pycache__/sequence_history.cpython-312.pyc create mode 100644 src/services/__pycache__/sequence_processor.cpython-312.pyc create mode 100644 src/services/sequence_processor.py rename src/{services/sequence_history.py => utils/File_Handler.py} (52%) create mode 100644 src/utils/__init__.py create mode 100644 src/utils/__pycache__/File_Handler.cpython-312.pyc create mode 100644 src/utils/__pycache__/__init__.cpython-312.pyc diff --git a/cherrypy.log b/cherrypy.log new file mode 100644 index 0000000..d766aab --- /dev/null +++ b/cherrypy.log @@ -0,0 +1,105 @@ +[29/Apr/2024:11:47:35] ENGINE Bus STARTING +[29/Apr/2024:11:47:35] ENGINE Started monitor thread 'Autoreloader'. +[29/Apr/2024:11:47:35] ENGINE Serving on http://0.0.0.0:8080 +[29/Apr/2024:11:47:35] ENGINE Bus STARTED +[29/Apr/2024:11:47:37] ENGINE Keyboard Interrupt: shutting down bus +[29/Apr/2024:11:47:37] ENGINE Bus STOPPING +[29/Apr/2024:11:47:37] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 8080)) shut down +[29/Apr/2024:11:47:37] ENGINE Stopped thread 'Autoreloader'. +[29/Apr/2024:11:47:37] ENGINE Bus STOPPED +[29/Apr/2024:11:47:37] ENGINE Bus EXITING +[29/Apr/2024:11:47:37] ENGINE Bus EXITED +[29/Apr/2024:11:47:37] ENGINE Waiting for child threads to terminate... +[29/Apr/2024:11:47:40] ENGINE Bus STARTING +[29/Apr/2024:11:47:40] ENGINE Started monitor thread 'Autoreloader'. +[29/Apr/2024:11:47:41] ENGINE Serving on http://0.0.0.0:8080 +[29/Apr/2024:11:47:41] ENGINE Bus STARTED +127.0.0.1 - - [29/Apr/2024:11:47:44] "GET /api/sequence HTTP/1.1" 200 151 "" "PostmanRuntime/7.37.3" +[29/Apr/2024:11:47:49] ENGINE Keyboard Interrupt: shutting down bus +[29/Apr/2024:11:47:49] ENGINE Bus STOPPING +[29/Apr/2024:11:47:49] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 8080)) shut down +[29/Apr/2024:11:47:49] ENGINE Stopped thread 'Autoreloader'. +[29/Apr/2024:11:47:49] ENGINE Bus STOPPED +[29/Apr/2024:11:47:49] ENGINE Bus EXITING +[29/Apr/2024:11:47:49] ENGINE Bus EXITED +[29/Apr/2024:11:47:49] ENGINE Waiting for child threads to terminate... +[29/Apr/2024:11:48:12] ENGINE Bus STARTING +[29/Apr/2024:11:48:12] ENGINE Started monitor thread 'Autoreloader'. +[29/Apr/2024:11:48:12] ENGINE Serving on http://0.0.0.0:8080 +[29/Apr/2024:11:48:12] ENGINE Bus STARTED +[29/Apr/2024:11:48:18] HTTP +Traceback (most recent call last): + File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\src\controller\sequence_controller.py", line 32, in GET + file_data = [seq.to_dict() for seq in sequencehistory.data] + ^^^^^^^^^^^^^ + File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\src\models\sequence.py", line 17, in to_dict + 'created_at': self.created_att + ^^^^^^^^^^^^^^^^ +AttributeError: 'Sequence' object has no attribute 'created_att'. Did you mean: 'created_at'? + +During handling of the above exception, another exception occurred: + +Traceback (most recent call last): + File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\.venv\Lib\site-packages\cherrypy\_cprequest.py", line 638, in respond + self._do_respond(path_info) + File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\.venv\Lib\site-packages\cherrypy\_cprequest.py", line 697, in _do_respond + response.body = self.handler() + ^^^^^^^^^^^^^^ + File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\.venv\Lib\site-packages\cherrypy\lib\encoding.py", line 223, in __call__ + self.body = self.oldhandler(*args, **kwargs) + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\.venv\Lib\site-packages\cherrypy\lib\jsontools.py", line 59, in json_handler + value = cherrypy.serving.request._json_inner_handler(*args, **kwargs) + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\.venv\Lib\site-packages\cherrypy\_cpdispatch.py", line 54, in __call__ + return self.callable(*self.args, **self.kwargs) + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\src\controller\sequence_controller.py", line 35, in GET + print(traceback.format_exc(e)) + ^^^^^^^^^^^^^^^^^^^^^^^ + File "C:\Program Files\Python312\Lib\traceback.py", line 184, in format_exc + return "".join(format_exception(sys.exception(), limit=limit, chain=chain)) + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "C:\Program Files\Python312\Lib\traceback.py", line 139, in format_exception + te = TracebackException(type(value), value, tb, limit=limit, compact=True) + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "C:\Program Files\Python312\Lib\traceback.py", line 733, in __init__ + self.stack = StackSummary._extract_from_extended_frame_gen( + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "C:\Program Files\Python312\Lib\traceback.py", line 411, in _extract_from_extended_frame_gen + if limit >= 0: + ^^^^^^^^^^ +TypeError: '>=' not supported between instances of 'AttributeError' and 'int' +[29/Apr/2024:11:48:18] HTTP +Request Headers: + Remote-Addr: 127.0.0.1 + USER-AGENT: PostmanRuntime/7.37.3 + ACCEPT: */* + POSTMAN-TOKEN: 286b7bfb-fddc-4889-b12e-7565ec4440aa + HOST: localhost:8080 + ACCEPT-ENCODING: gzip, deflate, br + CONNECTION: keep-alive +127.0.0.1 - - [29/Apr/2024:11:48:18] "GET /api/sequence HTTP/1.1" 500 3690 "" "PostmanRuntime/7.37.3" +[29/Apr/2024:11:48:41] ENGINE Keyboard Interrupt: shutting down bus +[29/Apr/2024:11:48:41] ENGINE Bus STOPPING +[29/Apr/2024:11:48:41] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 8080)) shut down +[29/Apr/2024:11:48:41] ENGINE Stopped thread 'Autoreloader'. +[29/Apr/2024:11:48:41] ENGINE Bus STOPPED +[29/Apr/2024:11:48:41] ENGINE Bus EXITING +[29/Apr/2024:11:48:41] ENGINE Bus EXITED +[29/Apr/2024:11:48:41] ENGINE Waiting for child threads to terminate... +[29/Apr/2024:11:50:17] ENGINE Bus STARTING +[29/Apr/2024:11:50:17] ENGINE Started monitor thread 'Autoreloader'. +[29/Apr/2024:11:50:17] ENGINE Serving on http://0.0.0.0:8080 +[29/Apr/2024:11:50:17] ENGINE Bus STARTED +127.0.0.1 - - [29/Apr/2024:11:50:25] "GET /api/sequence/aziz HTTP/1.1" 200 38 "" "PostmanRuntime/7.37.3" +127.0.0.1 - - [29/Apr/2024:11:51:01] "GET /api/sequence/dz_a_aazzaaa HTTP/1.1" 200 42 "" "PostmanRuntime/7.37.3" +127.0.0.1 - - [29/Apr/2024:11:51:08] "GET /api/sequence HTTP/1.1" 200 275 "" "PostmanRuntime/7.37.3" +[29/Apr/2024:11:51:23] ENGINE Keyboard Interrupt: shutting down bus +[29/Apr/2024:11:51:23] ENGINE Bus STOPPING +[29/Apr/2024:11:51:23] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 8080)) shut down +[29/Apr/2024:11:51:23] ENGINE Stopped thread 'Autoreloader'. +[29/Apr/2024:11:51:23] ENGINE Bus STOPPED +[29/Apr/2024:11:51:23] ENGINE Bus EXITING +[29/Apr/2024:11:51:23] ENGINE Bus EXITED +[29/Apr/2024:11:51:23] ENGINE Waiting for child threads to terminate... diff --git a/main_app - Copy.py b/main_app - Copy.py deleted file mode 100644 index b1b6fd3..0000000 --- a/main_app - Copy.py +++ /dev/null @@ -1,79 +0,0 @@ -def process_string_to_list(input_string): - """Convert the input string to a list of integers based on character positions, - where 'a' is 1, 'z' is 26, and '_' is 0.""" - converted_list = [] - i = 0 - n = len(input_string) - while i < n: - if 'a' <= input_string[i] <= 'z': - num_chars_to_consider = ord(input_string[i]) - ord('a') + 1 - converted_list.append(num_chars_to_consider) - i += 1 - elif input_string[i] == '_': - converted_list.append(0) - i += 1 - return converted_list - -def combine_consecutive_26s(converted_list): - """Combine all consecutive 26s in the list with the next non-26 value.""" - combined_list = [] - i = 0 - while i < len(converted_list): - if converted_list[i] == 26: - sum_26 = 0 - while i < len(converted_list) and converted_list[i] == 26: - sum_26 += converted_list[i] - i += 1 - if i < len(converted_list): - sum_26 += converted_list[i] - combined_list.append(sum_26) - i += 1 # Increment to skip the next element already added to sum_26 - else: - combined_list.append(converted_list[i]) - i += 1 - return combined_list - -def process_list(input_string): - """Process the input string to combine consecutive 26s with the next value.""" - converted_list = process_string_to_list(input_string) - combined_list = combine_consecutive_26s(converted_list) - return combined_list - -def create_result(input_string): - if input_string.startswith('_'): - return [0] - - combined_list = process_list(input_string) - results = [] - i = 0 - - while i < len(combined_list): - count = combined_list[i] if i < len(combined_list) else 0 - sum_sequence = 0 - if count > 0 and i + 1 < len(combined_list): - - sum_sequence = sum(combined_list[i + 1:i + 1 + count]) - - results.append(sum_sequence) - i += count + 1 - - if i >= len(combined_list) and (count == 0 or i + 1 >= len(combined_list)): - break - - return results - - -# Test the full processing function -print(create_result('abbcc')) -print(create_result('dz_a_aazzaaa')) -print(create_result('a_')) -print(create_result('abcdabcdab')) -print(create_result('abcdabcdab_')) -print(create_result('zdaaaaaaaabaaaaaaaabaaaaaaaabbaa')) -print(create_result('zza_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_')) -print(create_result('za_a_a_a_a_a_a_a_a_a_a_a_a_azaaa')) -print(create_result('_a')) -print(create_result('_')) -print(create_result('_ad')) -print(create_result('_zzzb')) -print(create_result('__')) diff --git a/main_app.py b/main_app.py index 8333030..1e74351 100644 --- a/main_app.py +++ b/main_app.py @@ -14,8 +14,19 @@ def index(self): """ pass - -cherrypy.config.update({'server.socket_host': '0.0.0.0', 'server.socket_port': 8080}) + # Set up logging + log_file = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'cherrypy.log') + cherrypy.log.error_file = log_file + cherrypy.log.access_file = log_file + + # Configure the global settings for CherryPy + cherrypy.config.update({ + 'server.socket_host': '0.0.0.0', + 'server.socket_port': 8080, + 'log.error_file': log_file, + 'log.screen': True, + 'log.access_file': log_file + }) # Mount the ContactsAPI application cherrypy.tree.mount(SequenceAPI(), '/api/sequence', { diff --git a/src/__init__.py b/src/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/__pycache__/__init__.cpython-312.pyc b/src/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..518218803bf80a544370cff87f561f45e0f65f4b GIT binary patch literal 169 zcmX@j%ge<81k()l(?IlN5P=Rpvj9b=GgLBYGWxA#C}INgK7-W!@^H3_2`x@7DvmKX zG&Qu0ami0E%}vcKDUJz9OwLYBPxVbrEG{id1&KN5=am6fX6ENP26)C47bVBU$7kkc nmc+;F6;%G>u*uC&Da}c>D`Ev2%m~EAAjU^#Mn=XWW*`dyss}2M literal 0 HcmV?d00001 diff --git a/src/abstraction/__init__.py b/src/abstraction/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/abstraction/__pycache__/__init__.cpython-312.pyc b/src/abstraction/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1659ddc719bb4ea2deea58860187cedc8398bc62 GIT binary patch literal 181 zcmX@j%ge<81U7E^X(0MBh(HIQS%4zb87dhx8U0o=6fpsLpFwJVg*aQqgche36~~wx zni^Whxa237=BDPA6vqT4CTAz6r~0NQ7MB*Kg2bHj^U8oKGxPHt13Y7ji;`m!lZs1< y5|c}SLNW32nR%Hd@$q^EmA^P_a`RJ4b5iY!Sb>%>0&y{j@sXL4k+Fyw$N~WWgD*?~ literal 0 HcmV?d00001 diff --git a/src/services/__pycache__/dataformat.cpython-312.pyc b/src/abstraction/__pycache__/dataformat.cpython-312.pyc similarity index 83% rename from src/services/__pycache__/dataformat.cpython-312.pyc rename to src/abstraction/__pycache__/dataformat.cpython-312.pyc index 3303097e04fe5805634f28abd5a4467c7dc84b6d..e62a583ecfea603dd66334f6184c4ea1782e9741 100644 GIT binary patch delta 30 mcmeyx_LptLbVkOo$uk&jxf7F$ONtVcOEUBGHs58O%Lo9vCJW#I delta 27 jcmey%_KR)9bVkPD$uk&jIf_$@$}*Evi#I=DoXZFRn2idj diff --git a/src/services/dataformat.py b/src/abstraction/dataformat.py similarity index 100% rename from src/services/dataformat.py rename to src/abstraction/dataformat.py diff --git a/src/controller/__init__.py b/src/controller/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/controller/__pycache__/__init__.cpython-312.pyc b/src/controller/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..882830b5aa771dc6726a34143b5b41b5788ca2d8 GIT binary patch literal 180 zcmX@j%ge<81hIztX(0MBh(HIQS%4zb87dhx8U0o=6fpsLpFwJV1v^{Cgche36~~wx zni^Whxa237=BDPA6vqT4CTAz6r~0NQ7MB*Kg2bHj^U8oKGxPHt13Y7ji;`oK^YcoI y@^f-hi(=yAGxIV_;^XxSDt~d<$R21ma>4<0CU8BV!RWkOctLAuj;{ literal 0 HcmV?d00001 diff --git a/src/controller/__pycache__/sequence_controller.cpython-312.pyc b/src/controller/__pycache__/sequence_controller.cpython-312.pyc index 0063fb06571374781854c07a13ac95a791731caa..396df3350c7b4ec4ccdbcb989aac96faf85f2a93 100644 GIT binary patch delta 1309 zcmZuwO>7%g5T3Vhf4u(BuiZK(zqs90I3b`EP>5(u)3hm76;q_Tsw~&L369or`*uSJ z@{%Hf;Fcyuf^y-#b++ZelXm8tdGoh3 z^B#onM#DdaLVlp<&UoMCXTnlAzA(uoP(ejHB~2sk(cs`M$SJ}tP4SvG)NXdWr@9}HelkmJj0H)ge&qNXf; z)6?7FNf$|_s2N6uP?Kg)IaV^v3YmYWqH6lm_SbKHhunhE6fN-{XK^aFut|0GQ^l)? z*y7E@gJb1DK&mavZI&>Vb-FT)&C zd>0&k^win&3g?K1Suke}hgS<`!Qs?vj+DKW$(+t+9e%P<(m#rpW&R^H;Ej)H2;w62*z7-Cp3P+wS=~~_`7-qp`mxZN(C`;7+V-d1y1%Pf-&?P5m|B9v_k4L%&86J6*jiLz`W%Ek<_Q zURtSawhh|{{E3BTh{kH+ClTmA>0WLPo_;uZZe#G=FKy#1#@+1wD_>ms^6Glq_@Ye7 z){E)y<&C2wOVXa-b^Loj1j+O0uiql^ec))OonXUl2q4L-cnzz6-DKLV6e8+=ZbhQ89sHi>W_>GB?n_LJmv_ delta 1063 zcmYjQO=ufO6n?X_KN?$F$+D@OSZc8&x!t%ZO-dsN+(2ZS^i+q69I_Xqde^GVO54nA za061DLl3$XY_`xsTkxSRF7~09LZGK6&`T~g3Zz-fkV_7|sc`}&xnySLbux$VeQ)14 z-+Ro?e3!bb>-Q3gA>eB#UtIn}-q6R_R(SR;SYROs%t1sZ3UkSn!iY`GqvXg9#Z-{c zU`K6erWSJ9i8Y8xLasPNjbU>bfdrSpQojOAv*X)XbObOHH;@tgSI|!k6sQ%C)|;rd z@lzp{40-J`b(d_$T)J`a%bbV8!BCC2{y}O>A|EUZ@5tMSSsQzY_5j<5^|tIkL=(pp zPm6Z6lq0>`QvHOKOK6tT(gw~g*)K_XsfGR1Xl%_=ceEpQjH_Y;6@iviffL~Ak!v1k zsZG3*DECGqwlWs6SFuGR*C- z3wZo}d4;)6ewI4(Tw1N!i_0!;RJ}l}T$!K$s8R_Kj$~>~41UHv2m}+s)3elYa`u+hq56c|+?Dg{uFb z5=b3;0um|o;v?S}57N`S>FLdD-L!E(ezN!G7r$P3lzgM3zvvS#ea>=x z$RE#ND8Zk(jKC5pm+&2Uw|oXGcg`r~l5eV)C+Tr6qXiDX!U0F1c>%Eq;{H8#^5U41 z*~CwPhXV}iTmMO%(NmGe(CLie;{wEm2_%;VBaAK;8?I$LtjLeL-mLjE+DZSkmRb9} zE`H$+stE1q>pJ_|b-TG_Q&m({_p=py$r}t)6y{+|G2rvq9Jjvi*yrh4o{IOu3=Vya l5ZZ&}9;EhQcn`>9$nV3sefVG>PCZq}QD%Mm837(cua}|C{96D3 diff --git a/src/controller/sequence_controller - Copy.py b/src/controller/sequence_controller - Copy.py deleted file mode 100644 index d332275..0000000 --- a/src/controller/sequence_controller - Copy.py +++ /dev/null @@ -1,80 +0,0 @@ -def process_string_to_list(input_string): - """Convert the input string to a list of integers based on character positions, - where 'a' is 1, 'z' is 26, and '_' is 0.""" - converted_list = [] - i = 0 - n = len(input_string) - while i < n: - if 'a' <= input_string[i] <= 'z': - num_chars_to_consider = ord(input_string[i]) - ord('a') + 1 - converted_list.append(num_chars_to_consider) - i += 1 - elif input_string[i] == '_': - converted_list.append(0) - i += 1 - return converted_list - - -def combine_consecutive_26s(converted_list): - """Combine all consecutive 26s in the list with the next non-26 value.""" - combined_list = [] - i = 0 - while i < len(converted_list): - if converted_list[i] == 26: - sum_26 = 0 - while i < len(converted_list) and converted_list[i] == 26: - sum_26 += converted_list[i] - i += 1 - if i < len(converted_list): - sum_26 += converted_list[i] - combined_list.append(sum_26) - i += 1 # Increment to skip the next element already added to sum_26 - else: - combined_list.append(converted_list[i]) - i += 1 - return combined_list - -def process_list(input_string): - """Process the input string to combine consecutive 26s with the next value.""" - converted_list = process_string_to_list(input_string) - combined_list = combine_consecutive_26s(converted_list) - return combined_list - -def create_result(input_string): - if input_string.startswith('_'): - return [0] - - combined_list = process_list(input_string) - results = [] - i = 0 - - while i < len(combined_list): - count = combined_list[i] if i < len(combined_list) else 0 - sum_sequence = 0 - if count > 0 and i + 1 < len(combined_list): - - sum_sequence = sum(combined_list[i + 1:i + 1 + count]) - - results.append(sum_sequence) - i += count + 1 - - if i >= len(combined_list) and (count == 0 or i + 1 >= len(combined_list)): - break - - return results - - -# Test the full processing function -print(create_result('abbcc')) -print(create_result('dz_a_aazzaaa')) -print(create_result('a_')) -print(create_result('abcdabcdab')) -print(create_result('abcdabcdab_')) -print(create_result('zdaaaaaaaabaaaaaaaabaaaaaaaabbaa')) -print(create_result('zza_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_')) -print(create_result('za_a_a_a_a_a_a_a_a_a_a_a_a_azaaa')) -print(create_result('_a')) -print(create_result('_')) -print(create_result('_ad')) -print(create_result('_zzzb')) -print(create_result('__')) diff --git a/src/controller/sequence_controller.py b/src/controller/sequence_controller.py index 8ee5ff1..8554995 100644 --- a/src/controller/sequence_controller.py +++ b/src/controller/sequence_controller.py @@ -1,12 +1,11 @@ import cherrypy import traceback -import json -import os -from src.models.string import String +from src.models.sequence import Sequence from src.services.sequence_service import SequenceService -from src.services.sequence_history import FileHandler -from src.models.sequence import StringProcessor +from src.utils.File_Handler import FileHandler +from src.services.sequence_processor import SequenceProcessor +from src.models.sequence_history import SequenceHistoryModel class SequenceAPI(object): @@ -15,24 +14,26 @@ class SequenceAPI(object): @cherrypy.tools.json_out() def GET(self, input_string: str = ""): res_msg = {"status": "FAIL", "data": []} - file_handler = FileHandler(storage_format='json') - sequence = SequenceService() + storage_type = "db" + file_handler = FileHandler(storage_type) + sequence = SequenceService(storage_type) + try: if input_string: - string_instance = String(input_string) - processor = StringProcessor(string_instance) + string_instance = Sequence(input_string) + processor = SequenceProcessor(string_instance) processed_results = processor.create_result() res_msg = {"status": "SUCCESS", "data": processed_results} sequence.process_and_store_string(input_string) else: - file_data = file_handler.open_write_file(state='r') + sequencehistory = SequenceHistoryModel() + file_data = [seq.to_dict() for seq in sequencehistory.data] res_msg = {"status": "SUCCESS", "data": file_data} except Exception as e: print(traceback.format_exc(e)) res_msg = {"status": "fail", "err_msg": "invalid sequence", "result": []} - #res_msg["data"] = str(e) return res_msg diff --git a/src/data/sequence_history.db b/src/data/sequence_history.db new file mode 100644 index 0000000000000000000000000000000000000000..514b55fb6a1b8261e2b9fdbcaa57cdf4935ca672 GIT binary patch literal 12288 zcmeI&%}N4M6bJBobu0*Kf}MGyr4!+hK`_uRAi?GDWOS=sSzcGVyDxX(1QN+=}sR{k+;PI0Rad=00Izz00bZa0SG_<0ucCxKrONmPo-$X z=gqF|4Z32ewLE(;vfb8f8a=8TMbltr@vv;Lnc9TQd-kq4nY?Y$#kiu-yYaN=do!!! zcz%C44x5L0YYlDg+igqC_LHJ7t&)@3T$1mJ{31Wg4`P9U00bZa0SG_<0uX=z z1Rwwb2teQu1ehd|9i<&u+~Pb4IOnRaW;I>k%d2TEr>j~#Dv^y851b&}$>h?7?0#l5 zB9XOJhkMiSxq>E6XlibYN+hoEX7ghwlTT;#yq=xR|5Sb@;zB?G0uX=z1Rwwb2tWV= U5P$##An@-6)@f9svwtl}Z>bN5g#Z8m literal 0 HcmV?d00001 diff --git a/src/data/store_sequence.db b/src/data/store_sequence.db new file mode 100644 index 0000000..c70c616 --- /dev/null +++ b/src/data/store_sequence.db @@ -0,0 +1,22 @@ +Data inserted: abbas at 2024-04-28 19:48:38 +Data inserted: abbas at 2024-04-28 19:48:39 +Data inserted: haitham at 2024-04-29 08:21:42 +Data inserted: haithamm at 2024-04-29 08:28:23 +Data inserted: haitham at 2024-04-29 08:31:16 +Data inserted: haitham at 2024-04-29 08:32:09 +Data inserted: haitham at 2024-04-29 08:33:01 +Data inserted: haitham at 2024-04-29 08:33:53 +Data inserted: abbcc at 2024-04-29 08:34:02 +Data inserted: abbcc at 2024-04-29 09:18:56 +Data inserted: abbcc at 2024-04-29 10:02:02 +Data inserted: abbas at 2024-04-29 10:02:19 +Data inserted: abbas at 2024-04-29 10:05:53 +Data inserted: abbas at 1714373747.562721 +Data inserted: abbas at 1714373849.5999064 +Data inserted: abbass at 1714374271.130031 +Data inserted: abbcc at 1714375632.7052374 +Data inserted: abbas at 1714375637.417899 +Data inserted: abbas at 1714375826.2767427 +Data inserted: has at 1714375831.3315036 +Data inserted: aziz at 1714377025.8492043 +Data inserted: dz_a_aazzaaa at 1714377061.357126 diff --git a/src/data/store_sequence.json b/src/data/store_sequence.json deleted file mode 100644 index 85c8e28..0000000 --- a/src/data/store_sequence.json +++ /dev/null @@ -1,5 +0,0 @@ -{"input_string": [52], "input_time": "2024-04-28 14:24:56"} -{"input_string": [52], "input_time": "2024-04-28 14:25:37"} -{"input_string": [52], "input_time": "2024-04-28 14:26:12"} -{"input_string": "haitham", "input_time": "2024-04-28 14:28:31"} -{"input_string": "za_a_a_a_a_a_a_a_a_a_a_a_a_azaaa", "input_time": "2024-04-28 14:28:54"} diff --git a/src/deserializers/__init__.py b/src/deserializers/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/models/__init__.py b/src/models/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/models/__pycache__/__init__.cpython-312.pyc b/src/models/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..31cdce528ff92ea9798ccc6e55c5434e3f411cfb GIT binary patch literal 176 zcmX@j%ge<81hIztX(0MBh(HIQS%4zb87dhx8U0o=6fpsLpFwJV`8!+1gche36~~w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b2rrW~y`FFK{bjn}$F5tsYgBIM22r56-=3fMgQD^AwqCu;E%Yw?q-TCCoE zXcH-+!`0E}(RUuo4^uUAY%Tgh^<2F_@$*2f|9JJ>({Nus99cTQcz!(`uZ80)Up))= zzYKwq+xk+_pnH>p@Zt=L8Xok|>K9qk8iywrUYvrFr@HQR=sKjSloR8yuHP&fId6pt zw78Y##u)#Jjx+)YcfAVq;=`K=m}~ei D7SF#RuN=^dRQG44~9SpNjf{5w0@HgIy%^4 zhh4=({{_eX6fYY?CUJtG7jLp21P|hS-!vNzAACRG_xru?`@RpQ(ikAIKeLS^2Jnr9 zjN}nByp7BNJn&cxOuD5O3z*3mNbm%_+!lE9u9SM4QjZzR4-#qyOH|K^{kR$UZfZ^u zD+wCjz-s_Ln9KuH^4J!bIZr~ADXXdUWJ5{v^_Vxq6?arYL=vCFGrTA=^jRNlVIb(i z4y*03q}U8Q-Pn#qxFIES-z7d#j5op@_A(4onM&0XFYDa-M|my$Xa&X z*UpN+ zMzIrg5*5FqL86fpgGrQBU!X0tg&&3KdNwS-({^78!^yBtRYi1-?jUT!(FJW#cw2Zk zzO8)MrVq85eQoCb!htq_s8#p1>fZg@f%bg6@U=X-r%sA#){H!@L+Av)Z6{;4jmy$) z5nr_JH(jTdS~wNqWr8aRJ0OC^S8|241azVage^Fhm|`5~nR0WOSCpyLo9y^v@(^Q5 qBWa0Fv;9^dq#Zou*U&)!5M4(2nPZH7hVd_O{a3!orj7wYg#86gg52N$ diff --git a/src/models/sequence.py b/src/models/sequence.py index 599079e..e8180b0 100644 --- a/src/models/sequence.py +++ b/src/models/sequence.py @@ -1,87 +1,18 @@ -from src.models.string import String +import time +from datetime import datetime -class StringProcessor: - def __init__(self, string_instance): - self.input_string = string_instance.get_string() - self.results = [] - self.converted_list = [] - self.combined_list = [] +class Sequence: + def __init__(self, input_string): + self.input_string = input_string + self.created_at = time.time() - def process_string_to_list(self): - """Convert the input string to a list of integers based on character positions, - where 'a' is 1, 'z' is 26, and '_' is 0.""" - for char in self.input_string: - if 'a' <= char <= 'z': - num_chars_to_consider = ord(char) - ord('a') + 1 - self.append_converted_list(num_chars_to_consider) - elif char == '_': - self.append_converted_list(0) + def get_string(self): + return self.input_string - def append_converted_list(self, value): - self.converted_list.append(value) - return self.converted_list - - def append_combined_list(self, num): - self.combined_list.append(num) - return self.combined_list - - def append_result(self, seq): - self.results.append(seq) - return self.results - - def handle_z_case(self): - """Combine all consecutive 26s in the list with the next non-26 value.""" - i = 0 - while i < len(self.converted_list): - if self.converted_list[i] == 26: - sum_26 = 0 - while i < len(self.converted_list) and self.converted_list[i] == 26: - sum_26 += self.converted_list[i] - i += 1 - if i < len(self.converted_list): - sum_26 += self.converted_list[i] - self.append_combined_list(sum_26) - i += 1 - else: - self.append_combined_list(self.converted_list[i]) - i += 1 - return self.combined_list - - def create_result(self): - """Process the input string to combine consecutive 26s with the next value and calculate sums.""" - if self.input_string.startswith('_'): - return [0] - - self.results = [] - converted_list = self.process_string_to_list() - combined_list = self.handle_z_case() - i = 0 - - while i < len(combined_list): - count = combined_list[i] if i < len(combined_list) else 0 - sum_sequence = 0 - if count > 0 and i + 1 < len(combined_list): - sum_sequence = sum(combined_list[i + 1:i + 1 + count]) - self.append_result(sum_sequence) - i += count + 1 - - if i >= len(combined_list) and (count == 0 or i + 1 >= len(combined_list)): - break - - return self.results - - -# Example usage -if __name__ == "__main__": - test_strings = [ - 'abbcc', 'dz_a_aazzaaa', 'a_', 'abcdabcdab', 'abcdabcdab_', - 'zdaaaaaaaabaaaaaaaabaaaaaaaabbaa', - 'zza_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_', - 'za_a_a_a_a_a_a_a_a_a_a_a_a_azaaa', '_a', '_', '_ad', '_zzzb', '__' - ] - - for test_string in test_strings: - processor = StringProcessor(test_string) - result = processor.create_result() - print(f"Input: {test_string} -> Got: {result}") + def to_dict(self): + """Convert the Sequence object attributes to a dictionary for easy JSON serialization.""" + return { + 'input_string': self.input_string, + 'created_at': self.created_at + } \ No newline at end of file diff --git a/src/models/sequence_history.py b/src/models/sequence_history.py new file mode 100644 index 0000000..9a33db1 --- /dev/null +++ b/src/models/sequence_history.py @@ -0,0 +1,37 @@ +from src.models.sequence import Sequence + + +import sqlite3 + + +class SequenceHistoryModel: + def __init__(self, db_path="./src/data/sequence_history.db"): + self.db_path = db_path + self.data = [] + self.load_sequences() + + def connect(self): + """ Establish a connection to the SQLite database. """ + return sqlite3.connect(self.db_path) + + def fetch_sequences_from_db(self): + """ + Fetches all sequences from the database and returns them as a list of dictionaries. + """ + sequences = [] + with self.connect() as conn: + cursor = conn.cursor() + cursor.execute("SELECT input_string, created_at FROM sequence_history") + rows = cursor.fetchall() + for row in rows: + sequences.append({'input_string': row[0], 'created_at': row[1]}) + return sequences + + def load_sequences(self): + """Load sequences from the database into the model.""" + sequences_from_db = self.fetch_sequences_from_db() + for seq in sequences_from_db: + # Assuming Sequence class now has a method or way to also store processed time + sequence = Sequence(seq['input_string']) + sequence.processed_time = seq['created_at'] # Dynamically add processed time if not in constructor + self.data.append(sequence) diff --git a/src/models/string.py b/src/models/string.py deleted file mode 100644 index e4cea97..0000000 --- a/src/models/string.py +++ /dev/null @@ -1,17 +0,0 @@ -import time -from datetime import datetime - - -class String: - def __init__(self, input_string): - self.input_string = input_string - - def get_string(self): - return self.input_string - - def epoch_time(self): - stamp = time.time() # Get current epoch time in seconds - # Convert epoch time to a datetime object and format it - date_time = datetime.fromtimestamp(stamp).strftime('%Y-%m-%d %H:%M:%S') - - return date_time diff --git a/src/serializers/JSONdataformat.py b/src/serializers/JSONdataformat.py new file mode 100644 index 0000000..a34932a --- /dev/null +++ b/src/serializers/JSONdataformat.py @@ -0,0 +1,13 @@ +import json + +from src.abstraction.dataformat import DataFormat +from src.models.sequence import Sequence + + +class JSONDataFormat(DataFormat): + def format(self, input_string: Sequence): + return json.dumps({ + "input_string": input_string.get_string(), + "input_time": input_string.created_at + }) + "\n" + diff --git a/src/serializers/SQLDataFormat.py b/src/serializers/SQLDataFormat.py new file mode 100644 index 0000000..98464f4 --- /dev/null +++ b/src/serializers/SQLDataFormat.py @@ -0,0 +1,29 @@ +import sqlite3 + +from src.abstraction.dataformat import DataFormat +from src.models.sequence import Sequence + + +class SQLDataFormat(DataFormat): + db_path = './src/data/sequence_history.db' # Define the database path at the class level if constant + + @staticmethod + def connect(): + """ Establish a connection to the SQLite database. """ + return sqlite3.connect(SQLDataFormat.db_path) + + def format(self, input_string: Sequence): + """ Insert the input string into the SQLite database with the current timestamp. """ + with self.connect() as conn: + cursor = conn.cursor() + cursor.execute(''' + CREATE TABLE IF NOT EXISTS sequence_history ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + input_string TEXT, + created_at TEXT + ); + ''') + cursor.execute('INSERT INTO sequence_history (input_string, created_at) VALUES (?, ?)', + (input_string.get_string(), input_string.created_at)) + conn.commit() + return f"Data inserted: {input_string.get_string()} at {input_string.created_at}" + "\n" diff --git a/src/serializers/__init__.py b/src/serializers/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/serializers/__pycache__/JSONdataformat.cpython-312.pyc b/src/serializers/__pycache__/JSONdataformat.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c21e5c46c33cca119f3302ce4d2b9331d7260d64 GIT binary patch literal 867 zcmY*XF>ljA6n=NM)8MqFqyj<6&b+`4L0Q}OM z$+E^^xQ^fu7%&onqdkpCOdU!zHX=zD0|aS z{jH9O{SdDfXGKz00g|>@C@w^gW@WKboEvE``UCkx%q!T$Rxt zMw?JGc4}12AXav+EDd9RL2Q(6?#WJ~ESAOlQrT@jQLXGia6jeD!}(BUN*=XFC8QR* zv~=NYth+BH7t&p8tTyhuo1Gwwd6G(Z*AHI%ZT^(|G80_KHaf{0WQLvO(e4vhionIh z(2v5N&ey|Z_!zCxW7PM%s*uCp_5bHu&%;F&AlJ~mgCAEHKlI-BPOHl&)s^Gw%D3w3 zY30sIrEy$ooLRl`m|%AKZIJ;1Qfv|S(oF_nBP9S>;`hC0xpUVa=j15Ej-ZgEh}gS1|j4-lzv0w RCoG>AEK>gH`~`HQ+<(7F%;^9C literal 0 HcmV?d00001 diff --git a/src/serializers/__pycache__/SQLDataFormat.cpython-312.pyc b/src/serializers/__pycache__/SQLDataFormat.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..69400e78d249e8be1332a810a320e572ab1d74bd GIT binary patch literal 1988 zcmaJ>OH3O_7@pZ(uN}wcm8J>Q3WIVemXIj|3MEyEAq#bZg<#WQ$E{iK4tO0uV0T@D z1qufaMU6zG9*C4w%C+LsW7SjDYcIAqfVQfH6!p-XE2tuI>de|(p6OVg`S+jif6V{- z&FggovL20h&i~8-@S1+u%TXf^2MDnZ6rjKih|!bDz$_DEAf?$1o8@901PmAj3bz3i z2WEEIs%*@$0{#47^h5MR(|u1eq>;Rql??Lb3ge{$&dFG=f~z}I`#9_%#5TYn1{Dxv z6c}SMr!X5}rv`{Q6c+RI46(_@oGT7LZ+gS`$4^WYZv{GaP3}~P(N4W)E0I!lBd@Il zl;jz+)M5HR{M0gQz?v11wjHt=Ug)XBM1lMMquEPj9l-H?(QRZk%a$@yFk z%Z8fIAtR5B6h_2j)xe1Qn3QxJKz`12>Ps2I>^7Y>yhg2RGl#J95;E)|0>6h9v_l3CXZP7gYK0 zoM9D(kQf%GBh;(OOCE8$kUP+cazFY!I6fnUQTt#A8uW|BdOCYZplJfIGJuL4A}$<5 zx1YB<%H&Ci^}J>}@nb9(3~ag=u-zi2`$RJV=CfJVAhUqeab{ktBY8JD+JRalA$2-` zXec!=z2N7qky?D`Y{OQ$^%Vb-Z0q2_+qf0qjDPcG1zf$-^4!?J-n{+r*~9O?_BjZ`{)=&%kYl~y(wo~-GOjjb2ld?FGFx`nnHm?*il=dVNO9d%Yz0v42 zGCibP4OPx!Bb8UINNY4e+D*FA{_YR-9f?E1L+#!s|Xa!W^|?ju`;g%JJ@>iz^>e}MKQ{#_`+Z$JA7(9`niUyDxC AumAu6 literal 0 HcmV?d00001 diff --git a/src/serializers/__pycache__/__init__.cpython-312.pyc b/src/serializers/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8366e6c2736e2f4c936db19f780cd3daca2ba368 GIT binary patch literal 181 zcmX@j%ge<81of`^X(0MBh(HIQS%4zb87dhx8U0o=6fpsLpFwJVg*aQqgche36~~wx zni^Whxa237=BDPA6vqT4CTAz6r~0NQ7MB*Kg2bHj^U8oKGxPHt13Y7ji;`o28Z#4f wGOIxPrx=J_D0UPN&( zpfjQyN~-jE6sD?|1Ov_#UUWQ6I?V{ug@OsZd(sIW!$>nyw<#7 zwIVkOXc%*A&vBnR`}96_c*3aow;P2Ai0nn-t-ZSzXRd|BgPu#dC3fWDuDkiJ8-ro0 z74B%`-}N<$-+2pHu!ZMvymt2G=*8&M#mmRF`p4Sl``YH4)`wd2M3pb-8OW9LRD;#( z$&y^DPC-6X&5(xIRnn4ehfY9kJJoGFh`huX{<3X9OB}z*unJ<|0$WGJ)`Sv^&(#t- zT&OW*lA=}%j7S?AE2Bxz;fRgJh>g?nm^gX5F0xpa`n*xxBj0#YU;`1SMQ5d*qP?5! hJSN1Ic@5Q6CWL&3@;7LFflEI$l~iAuKLJh7{SEbbzbya& diff --git a/src/services/__pycache__/SQLDataFormat.cpython-312.pyc b/src/services/__pycache__/SQLDataFormat.cpython-312.pyc deleted file mode 100644 index 10d342143a277aed354a7c4df53eb8c2b996f7dc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 760 zcmZ8f&ui2`6n>LmU3WLdL)m&<&`U0XA|i?i(o#`$sfZpzUQ~+KOpfa9=wUsOHaO+*#)OSBVlt0%)~&nYSXhC_vMRc|CLx>Ta_Zy*6K>saLy*@fS#5T*;J8qeEE9! ze)viWslvNEcXsZDdqrH$L|&@!Ad25chvK=2R3!!Fc8mN3m1&VbI(QN)8HafBB#ng% z*SheJ>c-)GTIKP(t@RU~-9T$a^E-vFyABq ziuh$)e9ca~d4{}($IUR!kE)WZQl|N#B9HM{()%{fw0nT7&FU;E)BvGt_S4|Q;G-*t z7*9OA>2aP%Gr@V&=X_QqRYrWs`EeCx`b2J`R$eFQ5zy7nR?-AIaF8g<&*8VhY`1lo zJ<>wb;4^Qi<18)3?PeRt?ytt~C;0Q|E+x%NS6p|w>^;zZJ(MGq&>+<|!Y`9C_6;_F Rfd9v_+34))U%;(%{Re$vt~vk! diff --git a/src/services/__pycache__/__init__.cpython-312.pyc b/src/services/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..db39581fdbf428c1072725799b803414b8393e21 GIT binary patch literal 178 zcmX@j%ge<81hIztX(0MBh(HIQS%4zb87dhx8U0o=6fpsLpFwJV1v*>Bgche36~~wx zni^Whxa237=BDPA6vqT4CTAz6r~0NQ7MB*Kg2bHj^U8oKGxPHt13Y7ji;`o28p|@1 vQ;TEb<1_OzOXB183Mzkb*yQG?l;)(`6|n+sUsSqlCT2{R5BUK+-_O&lDhT579Ql+X7`xYgYXw#RTJL6vz?L%*r zGxz7*bI(2JeCJ&MwY@!npq=Q8&HmPp&_CFq*7#~?v)S)_RGA;tU5<(!ae%W)CkH*AoM za8}2MQx}utk|~`rNJcVYCeSkSOqnFDUxWGfsUKZvEXj^EhgLv5UGeM49apT zx8k~oQoP~@DkwZqkK$8=dtA!P)Jpks-iY67JCoMbbCRxTD#`DT9ic=%qJU0EsA&*Y zr0UJAs>`ZeJBOX>uKsV_vCk}^>l~YIZ3XUGb(TW~u7Jckk15nRpH(}s%4FINr1@(7 z#`h68rNBKxkKMpq-=9MfS8|h!MLbqJRZWp8ZtHDzu#a?26=!YR5+>dXuytp`>KIE* zO^9dCUziXl6PM0eq4UYf%aG;fLsuDW$!O+Oi_h!Zo zIh#>+lg>;^@(nodhpI%gL}hcQ4gD5yrVTwYd42}WIs+STrDc^u$1$onmu70_V)Hr6 zCyHr3ZHi*PyU8Q5+H42Y;`>1EqKYqA_U$S9_AH-#|$E0eJD5Seu+HQcx80+%$qp9z6> zz3v8Q%xJ+?bNUpDaCsWQ)fS(Zh?K!;eLic7)Q;6qJIU@&V9=>r5%Tt+A5*&XP^A?lXB=#F?8t3jZ$cM z#WzeC^VY`y6jmMrN)+zKd!Tw}!wpRcsk=t+22PjF8QKy{bxv@c2SmTq088#VmTJil z0hair<)$|^i@#0{ov?%%5eO4t8`H)RVSz|OjC2C20>ic%X@iMYTeVhLY!73dIT-H3y>~vA<|WFZyD1~iA;|JuVeZV;P%3a@3fl3#?fcI?79XHzX~C> z$QStQP!Y z-P34+i}3kZbxg>HZc1sLVoB2+1QAt}Ou*1=R+ml4Q54gxJclJ3#UGKhsYdaSRY{5B z#QeOfE7&w}1_ao9>r$(jW=S>PghVFR0nWRe)PytRSc+m2#RkC(4Tc)%$3YmLl5T;F zsjLjilFnu|E!SV?jJPaLvbY6{Bgu$h@doH;$D<`IFvTrD0mZenu2M^2*q(DUovbFGG6c6`tt;sZOZr1AWh9fgxuK@hIm#fXwHm1@f=!p*f{W1TX{z0!x_At8#iaEmxt? zRI>CmRDXO!%|)SdL3K-0EJHoB>zpoS)L31h8oO34l5zZ@F{k5kL#;2`;c8?}D5!Cq zgnbR3D4v`%bQLGFnU7Tx$3w$Mk45nWAXsylesGQTW3rI}gewXGn8oqMjHK74Z*tLZ zSQ*KOt~A%oI3_G_=DksTDVJQAxGk&mEaOmb9tXlFUu%6kl-QNqb{RPi z!!M9sU!9`PAVL^n*sz~E_fTc~`*)M;JTIK*)`K45=z6CYx*J_>!f9?}Pe|x<_Oo4) zAYpaiav9X(O$ZsQ2cE*Q+EX~jegZXK<<2vGXA4KuD$gWsW2Y(xXmb(( diff --git a/src/services/__pycache__/sequence_processor.cpython-312.pyc b/src/services/__pycache__/sequence_processor.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5f82af1634aa71a0a7847b84a3633b4481653b02 GIT binary patch literal 4929 zcmc&&O>Emn79NtKOj(j8CGwAC#i9HYONyh^j%#OwBx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zk{@k0P|Hk!T%qk zb(cF&R2n>AbQFYgQ&ek;mX5@V4Y3-4F7|4kuB9VI&&f(4Sg==`nt$K1Ae7sBwYJ_; zu&>zEx2%>2uWN(Xzw6ZoZ>-)PDGrWQ{6ULmIjptyYySSim5RS{!T01!;nD_;np=K~ zOKETf!lA$M3uU3d+#1(f5Wz&xF7&K{1*i_Yg8?W1h0(VOn%g;;ObO%! zF@kpI(%@>=g$9Eq5OvxkH0YU+3dpY zMcAQ$T~gwwM2^$zIc_Q~WB{o--NkV;89rsckujdg zUR)Wr#JR8u|JaPCY2Sg?*T~3j%!C<-Lm5}tp_Lw}9-$4=Mzc%I7J|p7i=pG2evJybqaVipKHADbXp87j&A-X0ziu3HSE8YxqOM zIX3HHPhDg`NJH}`d?q;xm;X2zK};!e%lA#~8|v)E`f#bDVtt}ebmxwq?x=kwkg+{< zyLmixdK$j8sB%AyZCmI^=Dca{i}F=?fn$i0gldB#2;!e8@^AYvL4;l-TyNYWk&Kip_QEuEW)qR-}?-}}23Crkdmyrbd^mVFV;7b*E-dHeT_yHK~_EX*xl ZTe`dS(Q3oMOJ?wO9n9JAAzRQ8<$osTVs`)l literal 0 HcmV?d00001 diff --git a/src/services/__pycache__/sequence_service.cpython-312.pyc b/src/services/__pycache__/sequence_service.cpython-312.pyc index b3eae77e0c9a7658fb6a3f1e5a8f6fd28472bc55..3786686f0b61c88a8fed4dc9ab38478569715f51 100644 GIT binary patch delta 312 zcmbQkH;<3^G%qg~0}!lt)=&FAk@uu1M{sIkX=+|_swU$tK^S}Db5(UlkTM|nECD2@ zGo&&^F{Us?F{LoJFhnt@Fab%HN@h)#&8Cc(7#W#1b1*A1a&iu%s}yFh((_Ftsp5u~af^vTinKyu`@JxS5Mtk&&IP7;MyJ6P5{rLJ~80 zE(@x5u-y?+Uf_0FM0@g87EP9z%aUG`nOODN8E>&<73b$oHed}@`OL(~>dyF?jgQr^ zh#zQQ5j&8$#StH$o0ypwA73N~J}qdT$HSro1c=JQ>+KEs)!k+R2W%2wXifb zFFCb{1tcR2k||CtD$7hx1?qvy#b;y|m*f{!7O?`=fNd+1pX|%#%&0VZBAbq~%3TKi ny9}n^*@PGkKQaJ`4>}AiJRMb+m?dwDt8GZTB5phR0h=8FcvE1p diff --git a/src/services/sequence_processor.py b/src/services/sequence_processor.py new file mode 100644 index 0000000..d94f23d --- /dev/null +++ b/src/services/sequence_processor.py @@ -0,0 +1,87 @@ +from src.models.sequence import Sequence + + +class SequenceProcessor: + def __init__(self, string_instance: Sequence): + self.input_string = string_instance.get_string() + self.results = [] + self.converted_list = [] + self.combined_list = [] + + def process_string_to_list(self): + """Convert the input string to a list of integers based on character positions, + where 'a' is 1, 'z' is 26, and '_' is 0.""" + for char in self.input_string: + if 'a' <= char <= 'z': + num_chars_to_consider = ord(char) - ord('a') + 1 + self.append_converted_list(num_chars_to_consider) + elif char == '_': + self.append_converted_list(0) + + def append_converted_list(self, value): + self.converted_list.append(value) + return self.converted_list + + def append_combined_list(self, num): + self.combined_list.append(num) + return self.combined_list + + def append_result(self, seq): + self.results.append(seq) + return self.results + + def handle_z_case(self): + """Combine all consecutive 26s in the list with the next non-26 value.""" + i = 0 + while i < len(self.converted_list): + if self.converted_list[i] == 26: + sum_26 = 0 + while i < len(self.converted_list) and self.converted_list[i] == 26: + sum_26 += self.converted_list[i] + i += 1 + if i < len(self.converted_list): + sum_26 += self.converted_list[i] + self.append_combined_list(sum_26) + i += 1 + else: + self.append_combined_list(self.converted_list[i]) + i += 1 + return self.combined_list + + def create_result(self): + """Process the input string to combine consecutive 26s with the next value and calculate sums.""" + if self.input_string.startswith('_'): + return [0] + + self.results = [] + converted_list = self.process_string_to_list() + combined_list = self.handle_z_case() + i = 0 + + while i < len(combined_list): + count = combined_list[i] if i < len(combined_list) else 0 + sum_sequence = 0 + if count > 0 and i + 1 < len(combined_list): + sum_sequence = sum(combined_list[i + 1:i + 1 + count]) + self.append_result(sum_sequence) + i += count + 1 + + if i >= len(combined_list) and (count == 0 or i + 1 >= len(combined_list)): + break + + return self.results + + +# Example usage +if __name__ == "__main__": + test_strings = [ + 'abbcc', 'dz_a_aazzaaa', 'a_', 'abcdabcdab', 'abcdabcdab_', + 'zdaaaaaaaabaaaaaaaabaaaaaaaabbaa', + 'zza_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_', + 'za_a_a_a_a_a_a_a_a_a_a_a_a_azaaa', '_a', '_', '_ad', '_zzzb', '__' + ] + + for test_string in test_strings: + processor = SequenceProcessor(test_string) + result = processor.create_result() + print(f"Input: {test_string} -> Got: {result}") diff --git a/src/services/sequence_service.py b/src/services/sequence_service.py index 750f6b0..5478894 100644 --- a/src/services/sequence_service.py +++ b/src/services/sequence_service.py @@ -1,10 +1,10 @@ -from src.models.string import String -from src.models.sequence import StringProcessor -from src.services.sequence_history import FileHandler +from src.models.sequence import Sequence +from src.services.sequence_processor import SequenceProcessor +from src.utils.File_Handler import FileHandler class SequenceService: - def __init__(self, storage_format='json'): + def __init__(self, storage_format): self.file_handler = FileHandler(storage_format=storage_format) def process_and_store_string(self, input_string): @@ -12,12 +12,12 @@ def process_and_store_string(self, input_string): Takes an input string, processes it using StringProcessor, and stores the results. """ # Process the string using StringProcessor - string = String(input_string) - processor = StringProcessor(string) + sequence = Sequence(input_string) + processor = SequenceProcessor(sequence) processed_results = processor.create_result() # Convert results to the desired format (JSON, CSV, TXT) - formatted_data = self.file_handler.dataformat.format(input_string) + formatted_data = self.file_handler.dataformat.format(sequence) # Store the formatted data self.file_handler.open_write_file(data=formatted_data, state="a") @@ -26,7 +26,7 @@ def process_and_store_string(self, input_string): # Example usage if __name__ == "__main__": - sequence_service = SequenceService(storage_format='json') + sequence_service = SequenceService(storage_format='db') test_string = 'dz_a_aazzaaa' results, formatted = sequence_service.process_and_store_string(test_string) print(f"Processed Results: {results}, Formatted and Stored: {formatted}") diff --git a/src/services/sequence_history.py b/src/utils/File_Handler.py similarity index 52% rename from src/services/sequence_history.py rename to src/utils/File_Handler.py index 452814d..80b9135 100644 --- a/src/services/sequence_history.py +++ b/src/utils/File_Handler.py @@ -1,11 +1,6 @@ -import json -import os -import time - -from src.services.JSONdataformat import JSONDataFormat -from src.services.dataformat import DataFormat -from src.models.string import String -from src.services.SQLDataFormat import SQLDataFormat +from src.serializers.JSONdataformat import JSONDataFormat +from src.models.sequence import Sequence +from src.serializers.SQLDataFormat import SQLDataFormat class FileHandler: @@ -14,7 +9,7 @@ class FileHandler: def __init__(self, storage_format): self.set_datastore(storage_format) self.storage_format = storage_format - self.dataformat: DataFormat = JSONDataFormat() + self.dataformat = self.set_datastore(storage_format) self.INPUT_FILE_PATH = f"{self.BASE_FILE_PATH}.{storage_format}" def format_record(self, input_string): @@ -22,16 +17,16 @@ def format_record(self, input_string): :param input_string: input_string :return: chooses the format of file based on user input """ - inputstring = String(input_string) + inputstring = Sequence(input_string) return self.dataformat.format(inputstring) def set_datastore(self, storage_format): - if storage_format == 'sql': - self.dataformat = SQLDataFormat() + if storage_format == 'db': + return SQLDataFormat() # elif storage_format == 'txt': # self.dataformat = TXTDataFormat() elif storage_format == 'json': - self.dataformat = JSONDataFormat() + return JSONDataFormat() self.INPUT_FILE_PATH = f"{self.BASE_FILE_PATH}.{storage_format}" def open_write_file(self, data="", state="r"): @@ -46,21 +41,3 @@ def open_write_file(self, data="", state="r"): input_file.write(data) elif state == "r": return [x.strip() for x in input_file.readlines()] - - def read_contact(self, search): - """ - Search for a specific record based on unique key, in this case the name. - e.g: input: John Doe - output: Name: John Doe, Phone Number: 1234, Email: John@gmail.com, Address: Oman - """ - try: - inputs = self.open_write_file() - for strings in inputs: - string_details = strings.split(",") - - if string_details[1].strip().lower() == search.strip().lower(): - return f"[input_string: {string_details[0]}, Time {string_details[1]}]" - return "Not found" - except Exception as ex: - print("Error", ex) - diff --git a/src/utils/__init__.py b/src/utils/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/utils/__pycache__/File_Handler.cpython-312.pyc b/src/utils/__pycache__/File_Handler.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..cae16497058d92ca44d3597432cbe52f26ec8e73 GIT binary patch literal 2552 zcmai0T}%{L6ux(Uc9(_SMWCW9;sAxXvR#S|7>SXtph9D})YUX@XeZ;$po_CJc<(F- zU7|^OpovNU9-uL%K5BgNv9CV&g%vHEi9YqIZw5?EdFr_{`vZiuce7{iz31F>&YW|; zbLWpxD2QMTj`dA_=R@c(wx|rDJlQ$}lNF>P4I3zjGZ?cuXK*<_!@G0d5OQKh#E3%| zktQr5O?=9Er!&5JU(EkETg0#v{w)1PYE-e63l_;KHtYn_`t7`KsyfU==`SzUn5w71 zqh)Pq>jbPTWigBrJoQR1|i0Zb?Uc-G0C(Ito4PBmcz&vW<7dlS-2l5 zb@ps@4iq~F);b2CDZhu;PF-9(HnuFh3bbv3BD8-}Q@~k4b}e1iL@siWj%sR{25(G@ zm09gs;40})LuD_}pi~}1GYV01Qr4Ww+cLFD*1R#aYgLmZx}7KHkfh$UEUHt{^9QTcQ+#4#Yp#~TkDaN zYk`xb8RYg4z5$#Sz>9`&9S7HgwKO~h4jXC4<;q;_>M1~s zka9Tfx+6?e%OtGEVgh05But2e7zs1tzMoh9Ze$2+jJxBp3v;c&rk?_Va;-nSdgVoZ z$LnV4m*KUB&bK}kZd;vw5$b;3+_B!=wbsz}AC>9_tLidnWDS9>w*;usU6s0TbwVYU zYjyxF@&#y$vxqbm_{KJsky*u-~%3)V}4t1e^MDZM~uOSS-dHxQ64b9=0u<){4 z^{QpsO4g*3Vi+Dqh;Ar0pkyjmnAb4yluqRh zW4@y*8RHzRIC##%Bn3@fu)sgJ8Xa+tIquXEaNNk6I(0;b-kF%_!CPRCvORFZ33^y( z{ldX_D64L_7kLPeFs-tyPi7(uM|NU-4^x7(^jjc+@-PZF{rKTVQ%|v}=drjRO1wov z-3Wemq7-Ra4HhGvrN-z+qf~5^9<{t`>?s{MxZ3q|Td8+oqj$L2JG|bT{Im7kBV`r; z=Kt0Iu^dUr8hf`R8J5vfuZ-jbrnEksL7PDPK~Ip2 zJ`eB=0E7{SKiUpt36(zh_+DyL5X5o3+29jD*=+Q~^j%ZEID);S>_95!ciQ3NOF)m# zDn@nzuEPZT)Tv#=Zo6@snGpD>8x&-{4FvN7@0HJz ieqgXWjYfgI Date: Mon, 29 Apr 2024 13:34:33 +0400 Subject: [PATCH 03/12] another step + unittest --- cherrypy.log | 276 ++++++++++++++++++ main_app.py | 1 + .../__pycache__/dataformat.cpython-312.pyc | Bin 893 -> 888 bytes src/abstraction/dataformat.py | 2 +- .../sequence_controller.cpython-312.pyc | Bin 2072 -> 2072 bytes src/data/sequence_history.db | Bin 12288 -> 12288 bytes src/data/store_sequence.db | 3 + .../sequence_history.cpython-312.pyc | Bin 2303 -> 2796 bytes src/models/sequence_history.py | 42 ++- src/serializers/JSONdataformat.py | 5 + src/serializers/SQLDataFormat.py | 8 +- .../JSONdataformat.cpython-312.pyc | Bin 867 -> 1076 bytes .../__pycache__/SQLDataFormat.cpython-312.pyc | Bin 1988 -> 2022 bytes .../sequence_processor.cpython-312.pyc | Bin 4929 -> 5438 bytes src/services/sequence_processor.py | 30 +- .../test_sequence_processor.cpython-312.pyc | Bin 0 -> 1819 bytes .../unittest/test_sequence_processor.py | 41 +++ src/utils/File_Handler.py | 8 +- .../__pycache__/File_Handler.cpython-312.pyc | Bin 2552 -> 2761 bytes 19 files changed, 392 insertions(+), 24 deletions(-) create mode 100644 src/services/unittest/__pycache__/test_sequence_processor.cpython-312.pyc create mode 100644 src/services/unittest/test_sequence_processor.py diff --git a/cherrypy.log b/cherrypy.log index d766aab..7490642 100644 --- a/cherrypy.log +++ b/cherrypy.log @@ -103,3 +103,279 @@ Request Headers: [29/Apr/2024:11:51:23] ENGINE Bus EXITING [29/Apr/2024:11:51:23] ENGINE Bus EXITED [29/Apr/2024:11:51:23] ENGINE Waiting for child threads to terminate... +[29/Apr/2024:11:52:50] ENGINE Bus STARTING +[29/Apr/2024:11:52:50] ENGINE Started monitor thread 'Autoreloader'. +[29/Apr/2024:11:52:50] ENGINE Serving on http://0.0.0.0:8080 +[29/Apr/2024:11:52:50] ENGINE Bus STARTED +127.0.0.1 - - [29/Apr/2024:11:53:00] "GET /api/sequence/ahmed HTTP/1.1" 200 37 "" "PostmanRuntime/7.37.3" +127.0.0.1 - - [29/Apr/2024:11:53:04] "GET /api/sequence HTTP/1.1" 200 340 "" "PostmanRuntime/7.37.3" +[29/Apr/2024:11:53:20] ENGINE Keyboard Interrupt: shutting down bus +[29/Apr/2024:11:53:20] ENGINE Bus STOPPING +[29/Apr/2024:11:53:20] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 8080)) shut down +[29/Apr/2024:11:53:20] ENGINE Stopped thread 'Autoreloader'. +[29/Apr/2024:11:53:20] ENGINE Bus STOPPED +[29/Apr/2024:11:53:20] ENGINE Bus EXITING +[29/Apr/2024:11:53:20] ENGINE Bus EXITED +[29/Apr/2024:11:53:20] ENGINE Waiting for child threads to terminate... +[29/Apr/2024:11:53:28] ENGINE Bus STARTING +[29/Apr/2024:11:53:28] ENGINE Started monitor thread 'Autoreloader'. +[29/Apr/2024:11:53:28] ENGINE Serving on http://0.0.0.0:8080 +[29/Apr/2024:11:53:28] ENGINE Bus STARTED +127.0.0.1 - - [29/Apr/2024:11:53:45] "GET /api/sequence/ahmed HTTP/1.1" 200 37 "" "PostmanRuntime/7.37.3" +[29/Apr/2024:11:54:09] ENGINE Keyboard Interrupt: shutting down bus +[29/Apr/2024:11:54:09] ENGINE Bus STOPPING +[29/Apr/2024:11:54:09] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 8080)) shut down +[29/Apr/2024:11:54:09] ENGINE Stopped thread 'Autoreloader'. +[29/Apr/2024:11:54:09] ENGINE Bus STOPPED +[29/Apr/2024:11:54:09] ENGINE Bus EXITING +[29/Apr/2024:11:54:09] ENGINE Bus EXITED +[29/Apr/2024:11:54:09] ENGINE Waiting for child threads to terminate... +[29/Apr/2024:13:22:24] ENGINE Bus STARTING +[29/Apr/2024:13:22:24] ENGINE Started monitor thread 'Autoreloader'. +[29/Apr/2024:13:22:24] ENGINE Serving on http://0.0.0.0:8080 +[29/Apr/2024:13:22:24] ENGINE Bus STARTED +127.0.0.1 - - [29/Apr/2024:13:22:57] "GET /api/sequence/ahmed HTTP/1.1" 200 37 "" "PostmanRuntime/7.37.3" +127.0.0.1 - - [29/Apr/2024:13:23:19] "GET /api/sequence/dzzzzaaaaa HTTP/1.1" 200 39 "" "PostmanRuntime/7.37.3" +127.0.0.1 - - [29/Apr/2024:13:23:24] "GET /api/sequence/dzzzzaaaaaa HTTP/1.1" 200 39 "" "PostmanRuntime/7.37.3" +[29/Apr/2024:13:23:33] HTTP +Traceback (most recent call last): + File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\src\controller\sequence_controller.py", line 31, in GET + sequencehistory = SequenceHistoryModel() + ^^^^^^^^^^^^^^^^^^^^^^ + File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\src\models\sequence_history.py", line 11, in __init__ + self.load_sequences() + File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\src\models\sequence_history.py", line 36, in load_sequences + sequences_from_db = self.fetch_sequences_from_db() + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\src\models\sequence_history.py", line 26, in fetch_sequences_from_db + cursor.execute("SELECT input_string, created_at FROM sequence_history") +sqlite3.OperationalError: no such table: sequence_history + +During handling of the above exception, another exception occurred: + +Traceback (most recent call last): + File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\.venv\Lib\site-packages\cherrypy\_cprequest.py", line 638, in respond + self._do_respond(path_info) + File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\.venv\Lib\site-packages\cherrypy\_cprequest.py", line 697, in _do_respond + response.body = self.handler() + ^^^^^^^^^^^^^^ + File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\.venv\Lib\site-packages\cherrypy\lib\encoding.py", line 223, in __call__ + self.body = self.oldhandler(*args, **kwargs) + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\.venv\Lib\site-packages\cherrypy\lib\jsontools.py", line 59, in json_handler + value = cherrypy.serving.request._json_inner_handler(*args, **kwargs) + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\.venv\Lib\site-packages\cherrypy\_cpdispatch.py", line 54, in __call__ + return self.callable(*self.args, **self.kwargs) + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\src\controller\sequence_controller.py", line 35, in GET + print(traceback.format_exc(e)) + ^^^^^^^^^^^^^^^^^^^^^^^ + File "C:\Program Files\Python312\Lib\traceback.py", line 184, in format_exc + return "".join(format_exception(sys.exception(), limit=limit, chain=chain)) + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "C:\Program Files\Python312\Lib\traceback.py", line 139, in format_exception + te = TracebackException(type(value), value, tb, limit=limit, compact=True) + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "C:\Program Files\Python312\Lib\traceback.py", line 733, in __init__ + self.stack = StackSummary._extract_from_extended_frame_gen( + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "C:\Program Files\Python312\Lib\traceback.py", line 411, in _extract_from_extended_frame_gen + if limit >= 0: + ^^^^^^^^^^ +TypeError: '>=' not supported between instances of 'OperationalError' and 'int' +[29/Apr/2024:13:23:33] HTTP +Request Headers: + Remote-Addr: 127.0.0.1 + USER-AGENT: PostmanRuntime/7.37.3 + ACCEPT: */* + POSTMAN-TOKEN: 221889de-b550-4a77-a5ef-c9cf3ccc1ef8 + HOST: localhost:8080 + ACCEPT-ENCODING: gzip, deflate, br + CONNECTION: keep-alive +127.0.0.1 - - [29/Apr/2024:13:23:33] "GET /api/sequence HTTP/1.1" 500 4061 "" "PostmanRuntime/7.37.3" +[29/Apr/2024:13:24:06] ENGINE Keyboard Interrupt: shutting down bus +[29/Apr/2024:13:24:06] ENGINE Bus STOPPING +[29/Apr/2024:13:24:07] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 8080)) shut down +[29/Apr/2024:13:24:07] ENGINE Stopped thread 'Autoreloader'. +[29/Apr/2024:13:24:07] ENGINE Bus STOPPED +[29/Apr/2024:13:24:07] ENGINE Bus EXITING +[29/Apr/2024:13:24:07] ENGINE Bus EXITED +[29/Apr/2024:13:24:07] ENGINE Waiting for child threads to terminate... +[29/Apr/2024:13:24:32] ENGINE Bus STARTING +[29/Apr/2024:13:24:32] ENGINE Started monitor thread 'Autoreloader'. +[29/Apr/2024:13:24:32] ENGINE Serving on http://0.0.0.0:8080 +[29/Apr/2024:13:24:32] ENGINE Bus STARTED +[29/Apr/2024:13:24:37] HTTP +Traceback (most recent call last): + File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\src\controller\sequence_controller.py", line 31, in GET + sequencehistory = SequenceHistoryModel() + ^^^^^^^^^^^^^^^^^^^^^^ + File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\src\models\sequence_history.py", line 11, in __init__ + self.load_sequences() + File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\src\models\sequence_history.py", line 36, in load_sequences + sequences_from_db = self.fetch_sequences_from_db() + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\src\models\sequence_history.py", line 26, in fetch_sequences_from_db + cursor.execute("SELECT input_string, created_at FROM sequence_history") +sqlite3.OperationalError: no such table: sequence_history + +During handling of the above exception, another exception occurred: + +Traceback (most recent call last): + File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\.venv\Lib\site-packages\cherrypy\_cprequest.py", line 638, in respond + self._do_respond(path_info) + File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\.venv\Lib\site-packages\cherrypy\_cprequest.py", line 697, in _do_respond + response.body = self.handler() + ^^^^^^^^^^^^^^ + File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\.venv\Lib\site-packages\cherrypy\lib\encoding.py", line 223, in __call__ + self.body = self.oldhandler(*args, **kwargs) + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\.venv\Lib\site-packages\cherrypy\lib\jsontools.py", line 59, in json_handler + value = cherrypy.serving.request._json_inner_handler(*args, **kwargs) + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\.venv\Lib\site-packages\cherrypy\_cpdispatch.py", line 54, in __call__ + return self.callable(*self.args, **self.kwargs) + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\src\controller\sequence_controller.py", line 35, in GET + print(traceback.format_exc(e)) + ^^^^^^^^^^^^^^^^^^^^^^^ + File "C:\Program Files\Python312\Lib\traceback.py", line 184, in format_exc + return "".join(format_exception(sys.exception(), limit=limit, chain=chain)) + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "C:\Program Files\Python312\Lib\traceback.py", line 139, in format_exception + te = TracebackException(type(value), value, tb, limit=limit, compact=True) + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "C:\Program Files\Python312\Lib\traceback.py", line 733, in __init__ + self.stack = StackSummary._extract_from_extended_frame_gen( + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "C:\Program Files\Python312\Lib\traceback.py", line 411, in _extract_from_extended_frame_gen + if limit >= 0: + ^^^^^^^^^^ +TypeError: '>=' not supported between instances of 'OperationalError' and 'int' +[29/Apr/2024:13:24:37] HTTP +Request Headers: + Remote-Addr: 127.0.0.1 + USER-AGENT: PostmanRuntime/7.37.3 + ACCEPT: */* + POSTMAN-TOKEN: 260e7b26-2d1f-4430-b6d6-745da750c454 + HOST: localhost:8080 + ACCEPT-ENCODING: gzip, deflate, br + CONNECTION: keep-alive +127.0.0.1 - - [29/Apr/2024:13:24:37] "GET /api/sequence HTTP/1.1" 500 4061 "" "PostmanRuntime/7.37.3" +127.0.0.1 - - [29/Apr/2024:13:24:42] "GET /api/sequence/abbas HTTP/1.1" 200 38 "" "PostmanRuntime/7.37.3" +127.0.0.1 - - [29/Apr/2024:13:24:47] "GET /api/sequence HTTP/1.1" 200 92 "" "PostmanRuntime/7.37.3" +[29/Apr/2024:13:25:04] ENGINE Keyboard Interrupt: shutting down bus +[29/Apr/2024:13:25:04] ENGINE Bus STOPPING +[29/Apr/2024:13:25:04] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 8080)) shut down +[29/Apr/2024:13:25:04] ENGINE Stopped thread 'Autoreloader'. +[29/Apr/2024:13:25:04] ENGINE Bus STOPPED +[29/Apr/2024:13:25:04] ENGINE Bus EXITING +[29/Apr/2024:13:25:04] ENGINE Bus EXITED +[29/Apr/2024:13:25:04] ENGINE Waiting for child threads to terminate... +[29/Apr/2024:13:29:06] ENGINE Bus STARTING +[29/Apr/2024:13:29:06] ENGINE Started monitor thread 'Autoreloader'. +[29/Apr/2024:13:29:06] ENGINE Serving on http://0.0.0.0:8080 +[29/Apr/2024:13:29:06] ENGINE Bus STARTED +[29/Apr/2024:13:29:08] HTTP +Traceback (most recent call last): + File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\src\controller\sequence_controller.py", line 31, in GET + sequencehistory = SequenceHistoryModel() + ^^^^^^^^^^^^^^^^^^^^^^ + File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\src\models\sequence_history.py", line 11, in __init__ + self.load_sequences() + File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\src\models\sequence_history.py", line 42, in load_sequences + for seq in sequences_from_db: +TypeError: 'NoneType' object is not iterable + +During handling of the above exception, another exception occurred: + +Traceback (most recent call last): + File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\.venv\Lib\site-packages\cherrypy\_cprequest.py", line 638, in respond + self._do_respond(path_info) + File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\.venv\Lib\site-packages\cherrypy\_cprequest.py", line 697, in _do_respond + response.body = self.handler() + ^^^^^^^^^^^^^^ + File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\.venv\Lib\site-packages\cherrypy\lib\encoding.py", line 223, in __call__ + self.body = self.oldhandler(*args, **kwargs) + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\.venv\Lib\site-packages\cherrypy\lib\jsontools.py", line 59, in json_handler + value = cherrypy.serving.request._json_inner_handler(*args, **kwargs) + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\.venv\Lib\site-packages\cherrypy\_cpdispatch.py", line 54, in __call__ + return self.callable(*self.args, **self.kwargs) + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\src\controller\sequence_controller.py", line 35, in GET + print(traceback.format_exc(e)) + ^^^^^^^^^^^^^^^^^^^^^^^ + File "C:\Program Files\Python312\Lib\traceback.py", line 184, in format_exc + return "".join(format_exception(sys.exception(), limit=limit, chain=chain)) + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "C:\Program Files\Python312\Lib\traceback.py", line 139, in format_exception + te = TracebackException(type(value), value, tb, limit=limit, compact=True) + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "C:\Program Files\Python312\Lib\traceback.py", line 733, in __init__ + self.stack = StackSummary._extract_from_extended_frame_gen( + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "C:\Program Files\Python312\Lib\traceback.py", line 411, in _extract_from_extended_frame_gen + if limit >= 0: + ^^^^^^^^^^ +TypeError: '>=' not supported between instances of 'TypeError' and 'int' +[29/Apr/2024:13:29:09] HTTP +Request Headers: + Remote-Addr: 127.0.0.1 + USER-AGENT: PostmanRuntime/7.37.3 + ACCEPT: */* + POSTMAN-TOKEN: 403e7db1-4799-4ea3-9ee4-031d650d70f5 + HOST: localhost:8080 + ACCEPT-ENCODING: gzip, deflate, br + CONNECTION: keep-alive +127.0.0.1 - - [29/Apr/2024:13:29:09] "GET /api/sequence HTTP/1.1" 500 3755 "" "PostmanRuntime/7.37.3" +[29/Apr/2024:13:29:28] ENGINE Keyboard Interrupt: shutting down bus +[29/Apr/2024:13:29:28] ENGINE Bus STOPPING +[29/Apr/2024:13:29:28] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 8080)) shut down +[29/Apr/2024:13:29:28] ENGINE Stopped thread 'Autoreloader'. +[29/Apr/2024:13:29:28] ENGINE Bus STOPPED +[29/Apr/2024:13:29:28] ENGINE Bus EXITING +[29/Apr/2024:13:29:28] ENGINE Bus EXITED +[29/Apr/2024:13:29:28] ENGINE Waiting for child threads to terminate... +[29/Apr/2024:13:29:57] ENGINE Bus STARTING +[29/Apr/2024:13:29:57] ENGINE Started monitor thread 'Autoreloader'. +[29/Apr/2024:13:29:57] ENGINE Serving on http://0.0.0.0:8080 +[29/Apr/2024:13:29:57] ENGINE Bus STARTED +127.0.0.1 - - [29/Apr/2024:13:30:00] "GET /api/sequence HTTP/1.1" 200 33 "" "PostmanRuntime/7.37.3" +[29/Apr/2024:13:30:17] ENGINE Keyboard Interrupt: shutting down bus +[29/Apr/2024:13:30:17] ENGINE Bus STOPPING +[29/Apr/2024:13:30:18] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 8080)) shut down +[29/Apr/2024:13:30:18] ENGINE Stopped thread 'Autoreloader'. +[29/Apr/2024:13:30:18] ENGINE Bus STOPPED +[29/Apr/2024:13:30:18] ENGINE Bus EXITING +[29/Apr/2024:13:30:18] ENGINE Bus EXITED +[29/Apr/2024:13:30:18] ENGINE Waiting for child threads to terminate... +[29/Apr/2024:13:30:24] ENGINE Bus STARTING +[29/Apr/2024:13:30:24] ENGINE Started monitor thread 'Autoreloader'. +[29/Apr/2024:13:30:25] ENGINE Serving on http://0.0.0.0:8080 +[29/Apr/2024:13:30:25] ENGINE Bus STARTED +127.0.0.1 - - [29/Apr/2024:13:30:26] "GET /api/sequence HTTP/1.1" 200 33 "" "PostmanRuntime/7.37.3" +[29/Apr/2024:13:30:34] ENGINE Keyboard Interrupt: shutting down bus +[29/Apr/2024:13:30:34] ENGINE Bus STOPPING +[29/Apr/2024:13:30:35] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 8080)) shut down +[29/Apr/2024:13:30:35] ENGINE Stopped thread 'Autoreloader'. +[29/Apr/2024:13:30:35] ENGINE Bus STOPPED +[29/Apr/2024:13:30:35] ENGINE Bus EXITING +[29/Apr/2024:13:30:35] ENGINE Bus EXITED +[29/Apr/2024:13:30:35] ENGINE Waiting for child threads to terminate... +[29/Apr/2024:13:30:38] ENGINE Bus STARTING +[29/Apr/2024:13:30:38] ENGINE Started monitor thread 'Autoreloader'. +[29/Apr/2024:13:30:38] ENGINE Serving on http://0.0.0.0:8080 +[29/Apr/2024:13:30:38] ENGINE Bus STARTED +127.0.0.1 - - [29/Apr/2024:13:30:58] "GET /api/sequence/dz_a_aazzaaa HTTP/1.1" 200 42 "" "PostmanRuntime/7.37.3" +127.0.0.1 - - [29/Apr/2024:13:31:02] "GET /api/sequence HTTP/1.1" 200 98 "" "PostmanRuntime/7.37.3" +[29/Apr/2024:13:34:02] ENGINE Keyboard Interrupt: shutting down bus +[29/Apr/2024:13:34:02] ENGINE Bus STOPPING +[29/Apr/2024:13:34:02] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 8080)) shut down +[29/Apr/2024:13:34:02] ENGINE Stopped thread 'Autoreloader'. +[29/Apr/2024:13:34:02] ENGINE Bus STOPPED +[29/Apr/2024:13:34:02] ENGINE Bus EXITING +[29/Apr/2024:13:34:02] ENGINE Bus EXITED +[29/Apr/2024:13:34:02] ENGINE Waiting for child threads to terminate... diff --git a/main_app.py b/main_app.py index 1e74351..a997712 100644 --- a/main_app.py +++ b/main_app.py @@ -28,6 +28,7 @@ def index(self): 'log.access_file': log_file }) + # Mount the ContactsAPI application cherrypy.tree.mount(SequenceAPI(), '/api/sequence', { '/': { diff --git a/src/abstraction/__pycache__/dataformat.cpython-312.pyc b/src/abstraction/__pycache__/dataformat.cpython-312.pyc index e62a583ecfea603dd66334f6184c4ea1782e9741..b17d24d3d2d21d28b167aa533c7fcc0d5e0fcc2e 100644 GIT binary patch delta 40 ucmey%_JfW0G%qg~0}$*@(N7DV$m_@0Ffpc#(<|8DPe&m*&}ZX=xl91`$_$7A delta 45 zcmeyt_Lq(KG%qg~0}xD5)=P_;$m_@0Ix(h2KpR`#}poyPJfo1XodC^33a|1I& zJ!4aILt}Af76wu6#H!3HLvuqDW1x(Ysh)+2rI8pD3xlwBMq)8U+|c+T-u^U(&DzHKqw`~g9lAY z)>w@PIg)TtZk~)K9yDIs0O@9foIDv1Jkt&7t?=Xm*k^!XRetCi^|KfNS#S@eFjkQ$ zw{i_v(;kp0cSK#iKsKkS1dn`VVQK|dAj7~22$Lylo|+*mdlE|+DqOkFlA_Pl(R1{Q zuEHKy((`n=67ESX38wK8ki-JatYRZR*=G%X;}a3FKb8>3VpGwuM)t~bOb#&0HsK%D zjEIF~AL7c4Mo!A((S*kKPKP3siSbx8z{uz`G&UZ2I2DP8B5{of#iCK!g0h4hOU5-E zqDG9tW|}TC9cLgTib^{b6r^*V1oDG8!Y;P^ z3ckkZyKVTIjcY=Im+S7p*E&e(hmKW;%>W?b!r|K6hL8nla$XD)|BQ_#MVyfzpCkT~ zpGXn�(KG?`PyEXS+}4RaCa9R@Z4HBSmBr0yBjE04;kI2VE=JQOb$H0Uv_(lTK&6#;2SgecZX-GXW3BjcCI@v zXBf4id3mDHa5ckh2tHLXW!XixD2N3?T(WHn4Ld9>`n6vL1pEILumNBPkEAMz2RWXV zn(&;3lYDs2M?zmYq=zt%GQhO*1lhdH38Z_^%aLy7DRU8PQa&)Yzy)}1^!wxJ@j_KG W>>Kd!Q2?txpc*hZS`cLPLjM4EeE@3! delta 574 zcmaDO`d^UmG%qg~0}v?r>!($)ZshZ4Vlj4nC{Ut-;R(Oke1Cwv z=?v)%wTv|kS&S3^Nlgx9zQLr)HhDSAQ6^2+$*rs!x|(c7AmeUv7N-`LrsgH57T;n? z&d29OBX1z% z1m+t8lGgH&NGxM7XJyu8sWOv@Ru?!VZwRY=VqoD^?{I!1F28_zf!{?1 zv(xiBkIY3LnHdpRdDK2~0yP!!f-HE>8Nw(#*@nx2mx)#P69+e|8AxTZshZ0Wb~V?!*r3;94OepaED)bG6!=v2Mepv0*fyU XER$z5ck#0_3QdUm$^fK_gn+65W&RLB diff --git a/src/serializers/__pycache__/SQLDataFormat.cpython-312.pyc b/src/serializers/__pycache__/SQLDataFormat.cpython-312.pyc index 69400e78d249e8be1332a810a320e572ab1d74bd..531f6ffe6f0c17bb95440e2268f2df042e6d2c41 100644 GIT binary patch delta 153 zcmX@Y|BRpaG%qg~0}y;q(NDX#kvEi)(}7C?0wyOj>T|$3lNi@Ba&2~Cn#jl*2N%4= z>nj6@F5&@d1pswiA_o8f delta 117 zcmaFHe}td+G%qg~0}y2U=%?-4$Q#PYXfQdOQGfCx#?cg6RX*0W(GE)4@^MT2M#{gM8*XcUl{l%d$D&5iZLcK OPVoB50HTX{fEob@JsiXU diff --git a/src/services/__pycache__/sequence_processor.cpython-312.pyc b/src/services/__pycache__/sequence_processor.cpython-312.pyc index 5f82af1634aa71a0a7847b84a3633b4481653b02..2374c5d627b2c245f45f6a8a644e501fe7d676cd 100644 GIT binary patch delta 1337 zcmaJ>&ubGw6wWl+bi2)uHCmOn=p@y&TcxcQJp>U%P%0=Dd+H^u$%HIycGH>N7E7f? z@X%AixrlnuqbHHzK?FfPiI)b7kp=&N9)wyCf+ye1Hc3@*4{ztq?0oZm?|ZZF@^8me zpOQ%}0?+%(WaUHZW$Fb&M&m8|g|rO~?>+o=^lrA31;`B0@-~7^0V>iSc;7Ihw2$A2 z*6YM6vk+JSbTMs5^yA?UNRuK}BqJsiVN6r-qDLSskKQ5+K5Jwg+i=p9U^;`0DT2P)-x@KVZjyG z!=s=ax9{Mp>6C4Pmy0En5h=c_rSP|Uhb)BR?OFHr4FYku5bZAyd9ujZtzcr7 zsutt2CTjKYqtlveNbsWBl1Ljb3Ql#RrCB6REFWyi&+N0g?Sj3-bmsdO4jDuZTCRA|Qb7dY2R~R-Kwj2){kd(V(kr;Pyz~$O_`juNBXpXHi%Kt7H=fNq(|_LO%mjEDzUCc3U#l zF#9n=dgET=SdX^UVaT7QuCAW$q!?NU2-+pzHa&s?p6z2dASejaLv||dgK?lS&!iq( zvb-vl)s_4W@mXH1M*)S7z{rS8;-MVbQKMpA;dANZ@DuRT)A|*dVEt{@3BB>iCPBfEO9lH1MnD#N>(gG%nl z_)%pT`fvWgM>N1sWUiqp?q9q dg0K@s2z`x={fy5eH2ggx;?4@+&dkNc-rri$P{9BI delta 812 zcmZXSO=uHA6vuaVv&*F2>}E|`YSM;H8q%g>twueGv_w#PkP3na4{>Q$8`z|AW>cY5 zD0r%u3Ul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0qWRn-uuSK3Q;E5hp{ps__$Uo8CRNC#O_ov0Ny|;56*{u9MSEY$ zLH@$WD@^AJ7kiLOoD5H~WGk+qfee_TsvhMEpo`gm!14p6psyuko8?Ih|`>6M} zHCGE8;8qm1MPh;zxP1CSN?3gNJf(fBETypXA6N z9pJP9A>dmfQZL3iC97e0*%)W@q>y1)#+Y4+!{}kK{RZjRVba;V(b;#w9{Kg*%NUX}4345tFeaX+K3-_Xb}=$%t9^7yPN>&^1r znj~ABkB6+)su-wAJ-Z)O#i5$i?vno9$*MS5le%~3ZQ}LHaOF}}jMSv}o((?(G*gq9 zPN`g}ieoj&YmHg2mfx>QKI=m(TAu%#D~MyM<#1nKImWby7Y(u literal 0 HcmV?d00001 diff --git a/src/services/unittest/test_sequence_processor.py b/src/services/unittest/test_sequence_processor.py new file mode 100644 index 0000000..9ee9dc2 --- /dev/null +++ b/src/services/unittest/test_sequence_processor.py @@ -0,0 +1,41 @@ +import unittest + +from src.models.sequence import Sequence +from src.services.sequence_processor import SequenceProcessor + +# tests to run +CURRENT_VS_EXPECTED_VALUE_MAPPING = ( + ("aa", [1]), + ("abbcc", [2, 6]), + ("dz_a_aazzaaa", [28, 53, 1]), + ("a_", [0]), + ("abcdabcdab", [2, 7, 7]), + ("abcdabcdab_", [2, 7, 7, 0]), + ("zdaaaaaaaabaaaaaaaabaaaaaaaabbaa", [34]), + ("zza_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_", [26]), + ("za_a_a_a_a_a_a_a_a_a_a_a_a_azaaa", [40, 1]), + ("_", [0]), + ("_ad", [0]), + ("a_", [0]), + ("_zzzb", [0]), + ("__", [0]) +) + + +class TestSequenceProcessor(unittest.TestCase): + + def test_sequence_processing(self): + """ + Tests the logic of the Sequence processor and checks whether the result is as expected + :return: Test OK + """ + for test_string, expected in CURRENT_VS_EXPECTED_VALUE_MAPPING: + sequence_instance = Sequence(test_string) + processor = SequenceProcessor(sequence_instance) + result = processor.create_result() + print(f"result {result} expected {expected}") + self.assertEqual(result, expected) + + +if __name__ == '__main__': + unittest.main() diff --git a/src/utils/File_Handler.py b/src/utils/File_Handler.py index 80b9135..0d22d38 100644 --- a/src/utils/File_Handler.py +++ b/src/utils/File_Handler.py @@ -21,10 +21,14 @@ def format_record(self, input_string): return self.dataformat.format(inputstring) def set_datastore(self, storage_format): + """ + + :param storage_format: changes format type based on what's written in the + controller. + :return: If it's db, then the db format is chosen, if JSON, the JSON format is chosen. + """ if storage_format == 'db': return SQLDataFormat() - # elif storage_format == 'txt': - # self.dataformat = TXTDataFormat() elif storage_format == 'json': return JSONDataFormat() self.INPUT_FILE_PATH = f"{self.BASE_FILE_PATH}.{storage_format}" diff --git a/src/utils/__pycache__/File_Handler.cpython-312.pyc b/src/utils/__pycache__/File_Handler.cpython-312.pyc index cae16497058d92ca44d3597432cbe52f26ec8e73..bf1838237d27a6b5c88ecf050452717f53682001 100644 GIT binary patch delta 344 zcmew%d{UI}G%qg~0}vFZ>ZkFtZ{)koQqQ8vT6La_O92Y33KEMFa}|n9@{1DFQ{&U} zi*gf7tQ3+n67$kiixnVzg_6pGRE4C(;?xv{{5*y7jKmW4VukXe%#xDSJcZ0Wg_4X^ zxQWU6c_l^pIXS6CdT=qTqSTVoqC6`F&-yflOpxZ3Bpr}0uvQ=kW>ID_(CYl+)I1%9 z%rphBV1GZbGB6864Z{3eOesmXSh9-q^NKiu-u2UDDPjfEMa&?A7ew%Z2z~~J$$YF9 zq96Dec%){8T;f)|Bdjpl{sNEE4PNQZ(X88;7*#e4aVRpfakF|devz7N$+>}FlhK*+ M69b4W5(XLq0CwJBlmGw# delta 108 zcmX>p`a_uSG%qg~0}z;b=%+QaZRESmBFv!4;&+QFCFvGRR&jn_5hqY~@=?|x(Hq>7 zGeRzLE8Y=Sm~4N6N9h9_1E0)h9ky*uj0&3{b0{*hv9o$Iei53?#kGN7mC>2;69b4W I5(XLo0DEj4mH+?% From c521179d09e0a0816aab92e2675e8b49878adc52 Mon Sep 17 00:00:00 2001 From: Abbas-Abdulrab <134558688+Abbas-Abdulrab@users.noreply.github.com> Date: Wed, 1 May 2024 08:29:56 +0400 Subject: [PATCH 04/12] Create README.md --- README.md | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..52a94a2 --- /dev/null +++ b/README.md @@ -0,0 +1,60 @@ +# Package Measurement Conversion + +## Overview + +This Measurement Conversion application allows users to input a character string and receive the output in JSON format. +The input is processed into a list showing the total values of measured inflows. +Accessible via a RESTful API endpoint, the application is designed with scalability and extensibility in mind, facilitating easy modifications and expansions. + +## Features +- **Sequence Input Handling:** Accepts a sequence of characters and underscores as input for conversion. +- **Efficient Conversion Algorithms:** Implements efficient algorithms for converting the input sequence into a list of measurements. +- **Clear and adaptable:** Easily modified and extended to include additional functionalities. +- **Handling Special Cases:** Handle special cases, such as, the charecter "z" which acts differently. + +## Installation +- Clone the following url in your command prompt: https://github.com/Abbas-Abdulrab/PackageMeasurementConversionAPI.git + +### Prerequisites +- Python 3.x +- CherryPy + +### Setup +1. Clone the repository (see the Installation section above). +2. Install required Python packages from requirements.txt: + ```pip install -r requirements.txt``` +## Usage +- Get a specific string: + + Default: http://localhost:8080/api/sequence/ + Specific port: http://localhost:/api/sequence/ + +- Get history of all conversions: + + Default: http://localhost:8080/api/sequence + + Specific port: http://localhost:/api/sequence + +### Running the Program +- **Script**: + + Default: ```python main.py``` + + Specific port: ```python main_app.py ``` +- **Access URL**: + + Default: http://localhost:8080/ + + Specific port: http://localhost:/ + +## Contributing +Contributions to this project are prohibited due to the course restrictions. + +## License +This project is licensed under the MIT License. + +## Contact +For any queries, please contact Abbas@gmail.com + +## Acknowledgements +Project by Abbas Abdul Rab From 29f2b01d9f233b601c8c1473a94a44b97cee6df3 Mon Sep 17 00:00:00 2001 From: Abbas Tawfiq Ali Abdulrab <71519@omantel.om> Date: Wed, 1 May 2024 08:54:15 +0400 Subject: [PATCH 05/12] gitignore --- .gitignore | 8 +++++ .idea/.gitignore | 3 -- .idea/.name | 1 - .idea/PackageMeasurementConversionAPI.iml | 10 ------ .../inspectionProfiles/profiles_settings.xml | 6 ---- .idea/misc.xml | 7 ---- .idea/modules.xml | 8 ----- .idea/vcs.xml | 6 ---- cherrypy.log | 32 ++++++++++++++++++ src/__pycache__/__init__.cpython-312.pyc | Bin 169 -> 0 bytes src/data/sequence_history.db | Bin 12288 -> 12288 bytes src/data/store_sequence.db | 4 +++ 12 files changed, 44 insertions(+), 41 deletions(-) create mode 100644 .gitignore delete mode 100644 .idea/.gitignore delete mode 100644 .idea/.name delete mode 100644 .idea/PackageMeasurementConversionAPI.iml delete mode 100644 .idea/inspectionProfiles/profiles_settings.xml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/vcs.xml delete mode 100644 src/__pycache__/__init__.cpython-312.pyc diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..09d6ca6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +.idea/ +*.png +*.jpg +*.gif +*.txt +*.csv +*.pdf +**/__pycache__/ diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 26d3352..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml diff --git a/.idea/.name b/.idea/.name deleted file mode 100644 index b5955c9..0000000 --- a/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -sequence.py \ No newline at end of file diff --git a/.idea/PackageMeasurementConversionAPI.iml b/.idea/PackageMeasurementConversionAPI.iml deleted file mode 100644 index 2c80e12..0000000 --- a/.idea/PackageMeasurementConversionAPI.iml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml deleted file mode 100644 index 105ce2d..0000000 --- a/.idea/inspectionProfiles/profiles_settings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 1b435f8..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index e89135d..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1dd..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/cherrypy.log b/cherrypy.log index 7490642..3eef523 100644 --- a/cherrypy.log +++ b/cherrypy.log @@ -379,3 +379,35 @@ Request Headers: [29/Apr/2024:13:34:02] ENGINE Bus EXITING [29/Apr/2024:13:34:02] ENGINE Bus EXITED [29/Apr/2024:13:34:02] ENGINE Waiting for child threads to terminate... +[01/May/2024:08:15:30] ENGINE Bus STARTING +[01/May/2024:08:15:30] ENGINE Started monitor thread 'Autoreloader'. +[01/May/2024:08:15:31] ENGINE Serving on http://0.0.0.0:8080 +[01/May/2024:08:15:31] ENGINE Bus STARTED +127.0.0.1 - - [01/May/2024:08:16:11] "GET /api/sequence HTTP/1.1" 200 99 "" "PostmanRuntime/7.37.3" +127.0.0.1 - - [01/May/2024:08:16:24] "GET /api/sequence/hhh HTTP/1.1" 200 35 "" "PostmanRuntime/7.37.3" +127.0.0.1 - - [01/May/2024:08:16:29] "GET /api/sequence HTTP/1.1" 200 158 "" "PostmanRuntime/7.37.3" +127.0.0.1 - - [01/May/2024:08:16:49] "GET /api/sequence/money HTTP/1.1" 200 35 "" "PostmanRuntime/7.37.3" +[01/May/2024:08:16:55] ENGINE Keyboard Interrupt: shutting down bus +[01/May/2024:08:16:55] ENGINE Bus STOPPING +[01/May/2024:08:16:55] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 8080)) shut down +[01/May/2024:08:16:55] ENGINE Stopped thread 'Autoreloader'. +[01/May/2024:08:16:55] ENGINE Bus STOPPED +[01/May/2024:08:16:55] ENGINE Bus EXITING +[01/May/2024:08:16:55] ENGINE Bus EXITED +[01/May/2024:08:16:55] ENGINE Waiting for child threads to terminate... +[01/May/2024:08:43:53] ENGINE Bus STARTING +[01/May/2024:08:43:53] ENGINE Started monitor thread 'Autoreloader'. +[01/May/2024:08:43:53] ENGINE Serving on http://0.0.0.0:8080 +[01/May/2024:08:43:53] ENGINE Bus STARTED +127.0.0.1 - - [01/May/2024:08:43:56] "GET /api/sequence HTTP/1.1" 200 219 "" "PostmanRuntime/7.37.3" +127.0.0.1 - - [01/May/2024:08:44:04] "GET /api/sequence/HI HTTP/1.1" 200 33 "" "PostmanRuntime/7.37.3" +127.0.0.1 - - [01/May/2024:08:44:09] "GET /api/sequence/hi HTTP/1.1" 200 34 "" "PostmanRuntime/7.37.3" +127.0.0.1 - - [01/May/2024:08:44:15] "GET /api/sequence HTTP/1.1" 200 335 "" "PostmanRuntime/7.37.3" +[01/May/2024:08:44:36] ENGINE Keyboard Interrupt: shutting down bus +[01/May/2024:08:44:36] ENGINE Bus STOPPING +[01/May/2024:08:44:36] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 8080)) shut down +[01/May/2024:08:44:36] ENGINE Stopped thread 'Autoreloader'. +[01/May/2024:08:44:36] ENGINE Bus STOPPED +[01/May/2024:08:44:36] ENGINE Bus EXITING +[01/May/2024:08:44:36] ENGINE Bus EXITED +[01/May/2024:08:44:36] ENGINE Waiting for child threads to terminate... diff --git a/src/__pycache__/__init__.cpython-312.pyc b/src/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index 518218803bf80a544370cff87f561f45e0f65f4b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 169 zcmX@j%ge<81k()l(?IlN5P=Rpvj9b=GgLBYGWxA#C}INgK7-W!@^H3_2`x@7DvmKX zG&Qu0ami0E%}vcKDUJz9OwLYBPxVbrEG{id1&KN5=am6fX6ENP26)C47bVBU$7kkc nmc+;F6;%G>u*uC&Da}c>D`Ev2%m~EAAjU^#Mn=XWW*`dyss}2M diff --git a/src/data/sequence_history.db b/src/data/sequence_history.db index 528a807a82f76a86d5425a2e3f54ea10072fa84a..5f6265737e97b4403dbc160f249c6af7586b4bad 100644 GIT binary patch delta 178 zcmZojXh@hK&B!)U#+i|AW5N=CK34uJ2L5~eNBLLrPvWoIEGUq{pCZP}!XT)dk!fgd zXkuz?VP;~fXJ%$-W+KJ{68G?gi<{_~TUZzwNiwrAi0kI&=cQIcq|6NrEcFa6%uNi% znOGQvbu%(DAQEPl7AATo=7xr*lkdrEu)Jd6f3;aq;THeI05&lZMrK{c;?%;@)V$=> N_>9crlKi4dRsg6uE7$-4 delta 68 zcmZojXh@hK&B!!S#+i|6W5N=CHb(w?4E*;t3o2aUpL|bVgXJ{?|7#%cCjZ0$4pCu7 XW?jzW)WXu#yyVpQjLhPa{Gv(# Date: Wed, 1 May 2024 09:02:15 +0400 Subject: [PATCH 06/12] remove cache --- cherrypy.log | 14 ++++++++++++++ .../__pycache__/__init__.cpython-312.pyc | Bin 181 -> 0 bytes .../__pycache__/dataformat.cpython-312.pyc | Bin 888 -> 0 bytes .../__pycache__/__init__.cpython-312.pyc | Bin 180 -> 0 bytes .../sequence_controller.cpython-312.pyc | Bin 2072 -> 0 bytes src/data/sequence_history.db | Bin 12288 -> 12288 bytes src/data/store_sequence.db | 1 + .../__pycache__/__init__.cpython-312.pyc | Bin 176 -> 0 bytes .../__pycache__/sequence.cpython-312.pyc | Bin 1078 -> 0 bytes .../sequence_history.cpython-312.pyc | Bin 2796 -> 0 bytes .../JSONdataformat.cpython-312.pyc | Bin 1076 -> 0 bytes .../__pycache__/SQLDataFormat.cpython-312.pyc | Bin 2022 -> 0 bytes .../__pycache__/__init__.cpython-312.pyc | Bin 181 -> 0 bytes .../__pycache__/__init__.cpython-312.pyc | Bin 178 -> 0 bytes .../sequence_processor.cpython-312.pyc | Bin 5438 -> 0 bytes .../sequence_service.cpython-312.pyc | Bin 1822 -> 0 bytes .../__pycache__/File_Handler.cpython-312.pyc | Bin 2761 -> 0 bytes .../__pycache__/__init__.cpython-312.pyc | Bin 175 -> 0 bytes 18 files changed, 15 insertions(+) delete mode 100644 src/abstraction/__pycache__/__init__.cpython-312.pyc delete mode 100644 src/abstraction/__pycache__/dataformat.cpython-312.pyc delete mode 100644 src/controller/__pycache__/__init__.cpython-312.pyc delete mode 100644 src/controller/__pycache__/sequence_controller.cpython-312.pyc delete mode 100644 src/models/__pycache__/__init__.cpython-312.pyc delete mode 100644 src/models/__pycache__/sequence.cpython-312.pyc delete mode 100644 src/models/__pycache__/sequence_history.cpython-312.pyc delete mode 100644 src/serializers/__pycache__/JSONdataformat.cpython-312.pyc delete mode 100644 src/serializers/__pycache__/SQLDataFormat.cpython-312.pyc delete mode 100644 src/serializers/__pycache__/__init__.cpython-312.pyc delete mode 100644 src/services/__pycache__/__init__.cpython-312.pyc delete mode 100644 src/services/__pycache__/sequence_processor.cpython-312.pyc delete mode 100644 src/services/__pycache__/sequence_service.cpython-312.pyc delete mode 100644 src/utils/__pycache__/File_Handler.cpython-312.pyc delete mode 100644 src/utils/__pycache__/__init__.cpython-312.pyc diff --git a/cherrypy.log b/cherrypy.log index 3eef523..901315b 100644 --- a/cherrypy.log +++ b/cherrypy.log @@ -411,3 +411,17 @@ Request Headers: [01/May/2024:08:44:36] ENGINE Bus EXITING [01/May/2024:08:44:36] ENGINE Bus EXITED [01/May/2024:08:44:36] ENGINE Waiting for child threads to terminate... +[01/May/2024:08:56:31] ENGINE Bus STARTING +[01/May/2024:08:56:31] ENGINE Started monitor thread 'Autoreloader'. +[01/May/2024:08:56:32] ENGINE Serving on http://0.0.0.0:8080 +[01/May/2024:08:56:32] ENGINE Bus STARTED +127.0.0.1 - - [01/May/2024:08:57:06] "GET /api/sequence HTTP/1.1" 200 330 "" "PostmanRuntime/7.37.3" +127.0.0.1 - - [01/May/2024:08:57:19] "GET /api/sequence/abbcc HTTP/1.1" 200 37 "" "PostmanRuntime/7.37.3" +[01/May/2024:08:57:27] ENGINE Keyboard Interrupt: shutting down bus +[01/May/2024:08:57:27] ENGINE Bus STOPPING +[01/May/2024:08:57:27] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 8080)) shut down +[01/May/2024:08:57:27] ENGINE Stopped thread 'Autoreloader'. +[01/May/2024:08:57:27] ENGINE Bus STOPPED +[01/May/2024:08:57:27] ENGINE Bus EXITING +[01/May/2024:08:57:27] ENGINE Bus EXITED +[01/May/2024:08:57:27] ENGINE Waiting for child threads to terminate... diff --git a/src/abstraction/__pycache__/__init__.cpython-312.pyc b/src/abstraction/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index 1659ddc719bb4ea2deea58860187cedc8398bc62..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 181 zcmX@j%ge<81U7E^X(0MBh(HIQS%4zb87dhx8U0o=6fpsLpFwJVg*aQqgche36~~wx zni^Whxa237=BDPA6vqT4CTAz6r~0NQ7MB*Kg2bHj^U8oKGxPHt13Y7ji;`m!lZs1< y5|c}SLNW32nR%Hd@$q^EmA^P_a`RJ4b5iY!Sb>%>0&y{j@sXL4k+Fyw$N~WWgD*?~ diff --git a/src/abstraction/__pycache__/dataformat.cpython-312.pyc b/src/abstraction/__pycache__/dataformat.cpython-312.pyc deleted file mode 100644 index b17d24d3d2d21d28b167aa533c7fcc0d5e0fcc2e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 888 zcmY*XPiqrF6rb7MtZ_{$wStF&4An~@M0yZWM5rl>qOnryVOba^yOU;d|HPSHCBZ`v zIe7Gz&rtdq`~;o_*^}VOTWb`dC*RvmY8}|OzxVg|-kbT{Y&rzar{LCLj}r17mF1}| zz`O%sMgroJfCffHW5YFK(={nE$YTnGMsxuUf67u~6n40A@rIm%^+@ zK&Qktr4<-caYh$xz73W6tVQXgxE8!OAS3uy#-V=W29Fs%ZYtdo_2jNxYnN(o0 zw2THC3$fEz-Fx1imP&hfHg9j<^|n(#k7bf+Z%6pA#lCzlh0c{kTQ^PKLS&dGTRTrY zt$c4eC73*HrR5#|l%6MwpE9jKdv=$-c%+#?&SB*i|2s)pOL9sR?e45AA?_t2Y#?y_SvL zCL)%c7Y^rf8srh;2Ip^b5mg@5fLMjCs8tk~QDA;ascb|jF2bkRK}^X{gVt^w+r++l z0;oARm#E6a=w7Q$R21ma>4<0CU8BV!RWkOctLAuj;{ diff --git a/src/controller/__pycache__/sequence_controller.cpython-312.pyc b/src/controller/__pycache__/sequence_controller.cpython-312.pyc deleted file mode 100644 index 348bb38bb29aa6687ab502b6e736c797e80385f2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2072 zcmZuyO>7fK6rSDndcBSvJK@JJNy=Xc7!^bM!*56hA%uS+3{^3PmDwE!yK8Tl9g_sv z6_u!(15$%jiB_V5V=68jdo4Zo5-X^2heV3h_Rw2OsMOL+-|TwrRAQuk^S!rk-@N(e zz1g3_;UI!>c64{{a~Yvux#A7bow1UG=>am3A($xb&O%xMT{Oj_l$Hc;lT2SxPRkDV znf{`ZRvavwfufpL9qc!Q#kO>tfJ8Kc4CO8|0yy+Ua+gVmCxwLi2UpG|1Qtl)n`Kh5Z;^fi=~ zj{!VD81ZeTMMFqS*jI3k7~g1RRV4<6}iyX^6*e=1p!sW6rxS0nlaRh zT4?wDTk|pWWl$GKkuF~CM5r391PdLlw;uAM+!yby^`UB8H3%8Cxf#K3VMSdO;Hd`3 z(N;tuk~?}4*^B)(Os1thr7sKIYcF1|0!~Wf9yc zFTxL-aMqbZEzQX5l&QlLIv%5WtHk6ns6nt$lGX9`to{iL<}6aoQVmb&i7@lo*vt{$ z2uy*coWw#res&aVbaD){P!1YVyWw^s3wYaM5x2axd2fj;!fs<+Td+H8a z>e)JTq1L%)N~y=Xra}v`EsqE0VtW9s;b_gCslc)?qJAX&66splvU6r&Zp;4Z$U^t7 z8EdY4a9XYR?wapCRO>x7*L!$2x_N0^a(4g8+J;lpNPyO6|ddB`b_2|ksSH8VE+kJXk1ySFY{9dhXIC@`M4muzH z^D>Nj&Io`17Ky(^BIL6W>i8-#-`Q8|?0bB3t~2pGw6nf>`|SJ2XD?i=t-o|{WGS+K zs{P+(l{>$-cf)QU4Ib@5KWvP1xi5A!?t9j*0Dcyix$IGg)=AI$dWWLYk5L&gzr#^N zWdThqWs6wTSWwf7mQjXk(O5{+ZkDrVo76Drr`k zLOoDIc0eBAp%svbZ0CYsS&ra0lD!MWT~u%Hyfd;ShrhV?*|mAOyC!$f$#4HD#^l&z z=_P_`MMD0Kj)A=AeV=G2NsiwF!PY=^Bq3L9+DWf6oZe$S{0$Tw{|mL=X$_0hq-;I+ zDbqZB%zsi^<1gj3G28g&0L|WTySwWR322SZa5|d#t?LD>QQ1o}SV-X!#M9D>Tco7Y}@^=Zb>At@ZOirBt0Ar>fkN^Mx diff --git a/src/data/sequence_history.db b/src/data/sequence_history.db index 5f6265737e97b4403dbc160f249c6af7586b4bad..3b75bf2552e288cf14b18f7fa52ea4c41a661d9f 100644 GIT binary patch delta 73 zcmZojXh@hK&B#7c#+i|QW5N=C0XF^w2L5~eNBLLrPvWoQPuQ#|;KMH^!N$TMuAP{a dl$>m6ZfIg^Y-wU_sb_9#X}-BizEyyc4FJ*r5^w+j delta 44 zcmZojXh@hK&B!)U#+i|AW5N=CK34uJ2L5~eNBLLrPvWoIEU1vdzqv}jRe+Hd03~n? AumAu6 diff --git a/src/data/store_sequence.db b/src/data/store_sequence.db index 7b59f00..0a36214 100644 --- a/src/data/store_sequence.db +++ b/src/data/store_sequence.db @@ -27,3 +27,4 @@ Data inserted: hhh at 1714536984.4711497 Data inserted: money at 1714537009.1874113 Data inserted: HI at 1714538644.7882183 Data inserted: hi at 1714538649.6616385 +Data inserted: abbcc at 1714539439.7597034 diff --git a/src/models/__pycache__/__init__.cpython-312.pyc b/src/models/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index 31cdce528ff92ea9798ccc6e55c5434e3f411cfb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 176 zcmX@j%ge<81hIztX(0MBh(HIQS%4zb87dhx8U0o=6fpsLpFwJV`8!+1gche36~~wx zni^Whxa237=BDPA6vqT4CTAz6r~0NQ7MB*Kg2bHj^U8oKGxPHt13Y7ji;`n<^HWlD tieuvAGxIV_;^XxSDt~d<00m2PQtgUZf#x#;aWRPTk(rT^v4|PS0s!r{=BA!+t zDAZ_Lzv$DG9rSMSIM=pFhn8J49ggCSrt+i`QM{H~SbCZd1cx?4&sVOIT9VgSg#$4p zdNX#mwD7R@QgR_{_vi1;Kd3DxL9@YQC2Pxm@Y-MFFSsw8f}?C9iQj-_l*CV#pVg!Y zYKrgQSFNv;93Dvf6Bp9bUAl{`CmCulee4 zm31B{<||mg#kRKk1~MuCEP`=Z5G6Tx5?E%v;!RA#WU$gf9jAJwIfp<5T&h!{f{ z0k}AV0hM?dtUc0CS?Wm&Xo;VBo1Emx)XdT3?BV3>G3;e-f9{uUj^s~>IhfbOD7!ga zaO^j@=cReigAdTGBR}kUn@zu-X#~a;qX<_4Iz&6`T?iYc2zVsg?2uE#uy39^)Sl_) zY&%P(ZCq0fqCL($^Spr^?nOsCa~@?CJQm|1!7fK6rR~1dmT2xDb5ed-FkU|4RM5$IA??QKny8fwY9%;QacFz%scJa2>LnJSSS#8~d*K!mBr3S{y~i*utKN8TqozeIH5 zF6T;*@(Wy8e2jxIwWSf`a>__Vjp3-f?9!qv*?I%UIbx7es*_Pp_vv(rj`BLUL`DU) zJ1Xh|P~U{-CxGNghGvKgoZBV|jHoxtkZIB5 z%l+LVOUVL!{&1ML{rb2%t65XFplg<9SH+W>uA0SNnPJWrOd~$Q{Ge!}dqsJEap36K z1=C>WSl{8^!|#rrN=8#NM#3`3&T7%mv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XzgjCt+WFOX5%^)ajhnlB;Ca!51+vH6tyjUi^>KJ#!Sf=a z%^0d`SEwo+Kq`*Btg4q&THIY>GI(+7l^cJI%=g5(Io(iUxKoaz0TDR Xh^6#T(y`?ubni1?Cxxm3#8LbYAnuN6 diff --git a/src/serializers/__pycache__/JSONdataformat.cpython-312.pyc b/src/serializers/__pycache__/JSONdataformat.cpython-312.pyc deleted file mode 100644 index 6dfa64582077b434ffcade88dccf0587c84e104f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1076 zcmY*Xy=xRf6rY*hy<9dQoaYC6Ua^(rnhQq=nnMIhP!x=TV6z-7lij&wll{2N%tmrp zSfsJiE{%n)Nwf(6~Igiv$0tP6X& z-FXFIMdyBNv9;7$iQOb*krbUZ>h91@_JUE7aHf3AakK}KejGhsd)5)$?LeYW1HZ5G z)z}n^VsgFxw3M6uoByv#Gk2E(fLH?Y7M)L{%8mE^cm31)+(~`mxW4eczIa-@cT#H| z*IH+WcGnyttui$zq1o!$gjT5zkTzKzLNe^Mk(M1Nq9Jpf)O4IM_L4x^(~h&7&>(-| zI>hp8AU-2rRdz)QwMm&!V->R?4$y#18r4q^&Jn0QR7EvPd2(zVAXp%pqn*gRXU%Rw%oxB$`C*Rt5x)ZuYJo)!#6ZIs|3Fi}QR^p~J1?2I M`oaE-KxMiA05eSxjQ{`u diff --git a/src/serializers/__pycache__/SQLDataFormat.cpython-312.pyc b/src/serializers/__pycache__/SQLDataFormat.cpython-312.pyc deleted file mode 100644 index 531f6ffe6f0c17bb95440e2268f2df042e6d2c41..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2022 zcmaJ>O-vg{6rR~#uN}wcFO3qYl?=+ESVBe!D3nwMLl)`+hG5fR$IY_r4tQPv!0x&P z3lt6w!{svn2#MA!is#GwM> zi~{2<<`iZV>{bDBhr(ihfgwJ*xO3Iv=S^?q;dsqO;ZC4K*W?a`IPK7@zQm-e8#!$? zpv<3hO9Q6=!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&X0awBmc6YfCsz<13v61u|wS(ZX?W!gFw_EIF$F{eIY~QZ0 zAw%2s4P^UHq=gI_jPP_U;2b3S3=?*1Bs)3Dahi)yGAzTg$t26NnuP_~*-4H!{+hGW zW;8m<1C3rL_cvfjI|p1aw|D*l?;|D|qA{$5&xvMbSY9KUWHLFaS>U5h&2{{hX@pKX z=u;QzYjJ4af^TFE@a3l;j3C71{<8NQ+Sk?j9%kiI1iAcuO4giJJjs;@Wai=^#eQ|?U7iZipc adVOtb?UT*Ap;y%K+Zvct^dVbN7v+EEUieP{ diff --git a/src/services/__pycache__/sequence_service.cpython-312.pyc b/src/services/__pycache__/sequence_service.cpython-312.pyc deleted file mode 100644 index 3786686f0b61c88a8fed4dc9ab38478569715f51..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1822 zcmZ`(&2Jk;6rWx1+Uu``HlfW{rd&L@i6B#WQJ~*t_ZM zy2zGW<&cB_gH)=JB2H9^M2{SE=VFsoPDjm&6SqK+kjjNO`(aF=Bkk(zW!X_e!NL5smijpK`xhmIU#h5S0s!B~QsuGgXJR-^l zBI>prL>J>ULE@|92(i43Xq+T=v~4N0X(U-pQf=kUu+qSbCL^yBWGbeM8Hmo36iq)t zBuz6<(6>tDA)!X5kukHsig;7vT7llLQ@cz-J{8G}%qdgXbr>kqbCoLn)UrvHvhqMt z6gGyA$3VM@C@M+>6=foApkj>3uq%z2sqo<_Yk{%{l`<`d)B3q$u#4yTlApwjlA@Nh zBSk&85bo<6$dnhJN_@!m9A@34c*$Wk%QI!BLI$2$f^PA0(5@+S#ii9HCjOf%${NP2 zyR*}!FI~#q(tDFrlkb;4amw`?wLQ1AXq8tX;~i?bbw-75*0CReXT`BUUc6ayS-Av( zVg?t405%+I@@oyQVO+5*9>&eF6Eo){OG0!q4BI+-nS1Biqy5}mTY0YO$Dl(0LIxNX zAj3h}M1#mgxIC0Sft|lva$g&3#a09uC)RfO{ZMJ4m58qcJ}cV5M<}kO|En9Qq`oFo z_J5*OBJIc#(1pFNaPTn##;9akJZoZ$IOO~Jmu{?{bu4j4FOfZ2S6F~E9nNiT;AdZQ# zc}h43^y2aGJ?yMe8-K$p;47$R##u)AX8ewE&@tB{cJO4_yTkaYXbcioarsb?)uRN9 zTCVsj0TfI?$j8DE4AVhwm@cf)96w30*LnKXUxj4r=#LZ{%{{)oH)6K6m!lWAmiI=l zw37$9i@n^nZtmJ%ZmOf{M{#uSd{4jJ)i3w-sjfcN(`UN+%#UB~>2vKNuqLxTP48-Y zPcyrk`Te8aLPsU~Hh@Wl5cvj^jh>WZ)^BM2(tNu_3QazGg|G%8(|u zuw^xy7HlJnA$^GPdBBQkqd7KV%=s4wVDEFMAkZb##)3J-N8qIApV6h^P94pIKk_-SeKHw4?!1X42X z=Fc(x#o0^G$o|>u9cA?3w6T8cKsS5(jjn!U_xhgxSywr;KHt9kLP>Tq7q$|Q8=diw VcJ^_+{*v} diff --git a/src/utils/__pycache__/File_Handler.cpython-312.pyc b/src/utils/__pycache__/File_Handler.cpython-312.pyc deleted file mode 100644 index bf1838237d27a6b5c88ecf050452717f53682001..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2761 zcmai0OH3O_7@pY&HpUMEG$hVzfrQ4vH6;~^f}&6Yc~GS;jT2R|XjdEW8cf!^WM&Pq zYZML~s1zxE9H5G#=9nm#9DB{VheAk-wMtGs^%g;-sGR!Gt{<49b`Za3=70MC|L-6F z76|wdtlL^|I^aR*Pj;v*p}g5V3!5dRA{FZ>i<20$J*RV7KFK?KUKg@rQpAWumyjwf zAXR+Ix!TEwd_%TR=%c<$;RKcd|kCsNw=ndcd>SZn~J!wabd3>KZBRkM&ZL z>Qy0vUTT>{lWEy~s^Wq9_Z)9UG=T)QY}FgcHq_f? zrw5ShB7T4#@*rEO1InWa7vI9Mh-e3>X36YpIN!n!vJYiKlhaOKZ69Nm_rdc+i3{?@ z(JL3^v7u|1?a*j^?E1CZ#S_jJsHUe$6F8B1G9DV%FTKMdua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ils/__pycache__/__init__.cpython-312.pyc b/src/utils/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index bd19c3a0f414dd282c451c61a59c80d67b92cac5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 175 zcmX@j%ge<81hIztX(0MBh(HIQS%4zb87dhx8U0o=6fpsLpFwJV`8iv~gche36~~wx zni^Whxa237=BDPA6vqT4CTAz6r~0NQ7MB*Kg2bHj^U8oKGxPHt13Y7ji;`nXOEPnc tW8&j8^D;}~ Date: Wed, 1 May 2024 09:04:57 +0400 Subject: [PATCH 07/12] requirements.txt --- .gitignore | 1 - requirements.txt | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 requirements.txt diff --git a/.gitignore b/.gitignore index 09d6ca6..37d69e1 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,6 @@ *.png *.jpg *.gif -*.txt *.csv *.pdf **/__pycache__/ diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..8115f67 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +CherryPy==18.9.0 +requests==2.31.0 + From cfa97fd4904db5f0c1d666a0d1838bcc5b6347fe Mon Sep 17 00:00:00 2001 From: Abbas Tawfiq Ali Abdulrab <71519@omantel.om> Date: Wed, 1 May 2024 09:22:45 +0400 Subject: [PATCH 08/12] chnaged main_app for dynamic port --- cherrypy.log | 53 +++++++++++++++++++++++++++++ main_app.py | 64 ++++++++++++++++++++--------------- src/data/sequence_history.db | Bin 12288 -> 12288 bytes src/data/store_sequence.db | 5 +++ 4 files changed, 95 insertions(+), 27 deletions(-) diff --git a/cherrypy.log b/cherrypy.log index 901315b..284c1d5 100644 --- a/cherrypy.log +++ b/cherrypy.log @@ -425,3 +425,56 @@ Request Headers: [01/May/2024:08:57:27] ENGINE Bus EXITING [01/May/2024:08:57:27] ENGINE Bus EXITED [01/May/2024:08:57:27] ENGINE Waiting for child threads to terminate... +[01/May/2024:09:14:16] ENGINE Bus STARTING +[01/May/2024:09:14:16] ENGINE Started monitor thread 'Autoreloader'. +[01/May/2024:09:14:16] ENGINE Serving on http://0.0.0.0:8080 +[01/May/2024:09:14:16] ENGINE Bus STARTED +127.0.0.1 - - [01/May/2024:09:14:20] "GET /api/sequence/abbcc HTTP/1.1" 200 37 "" "PostmanRuntime/7.37.3" +[01/May/2024:09:17:55] ENGINE Keyboard Interrupt: shutting down bus +[01/May/2024:09:17:55] ENGINE Bus STOPPING +[01/May/2024:09:17:55] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 8080)) shut down +[01/May/2024:09:17:55] ENGINE Stopped thread 'Autoreloader'. +[01/May/2024:09:17:55] ENGINE Bus STOPPED +[01/May/2024:09:17:55] ENGINE Bus EXITING +[01/May/2024:09:17:55] ENGINE Bus EXITED +[01/May/2024:09:17:55] ENGINE Waiting for child threads to terminate... +[01/May/2024:09:21:21] ENGINE Bus STARTING +[01/May/2024:09:21:21] ENGINE Started monitor thread 'Autoreloader'. +[01/May/2024:09:21:22] ENGINE Serving on http://0.0.0.0:8080 +[01/May/2024:09:21:22] ENGINE Bus STARTED +127.0.0.1 - - [01/May/2024:09:21:27] "GET /api/sequence/abbcc HTTP/1.1" 200 37 "" "PostmanRuntime/7.37.3" +[01/May/2024:09:21:30] ENGINE Keyboard Interrupt: shutting down bus +[01/May/2024:09:21:30] ENGINE Bus STOPPING +[01/May/2024:09:21:30] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 8080)) shut down +[01/May/2024:09:21:30] ENGINE Stopped thread 'Autoreloader'. +[01/May/2024:09:21:30] ENGINE Bus STOPPED +[01/May/2024:09:21:30] ENGINE Bus EXITING +[01/May/2024:09:21:30] ENGINE Bus EXITED +[01/May/2024:09:21:30] ENGINE Waiting for child threads to terminate... +[01/May/2024:09:21:42] ENGINE Bus STARTING +[01/May/2024:09:21:42] ENGINE Started monitor thread 'Autoreloader'. +[01/May/2024:09:21:42] ENGINE Serving on http://0.0.0.0:8888 +[01/May/2024:09:21:42] ENGINE Bus STARTED +127.0.0.1 - - [01/May/2024:09:21:50] "GET /api/sequence/abbcc HTTP/1.1" 200 37 "" "PostmanRuntime/7.37.3" +127.0.0.1 - - [01/May/2024:09:21:54] "GET /api/sequence/abbas HTTP/1.1" 200 38 "" "PostmanRuntime/7.37.3" +[01/May/2024:09:22:07] ENGINE Keyboard Interrupt: shutting down bus +[01/May/2024:09:22:07] ENGINE Bus STOPPING +[01/May/2024:09:22:07] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 8888)) shut down +[01/May/2024:09:22:07] ENGINE Stopped thread 'Autoreloader'. +[01/May/2024:09:22:07] ENGINE Bus STOPPED +[01/May/2024:09:22:07] ENGINE Bus EXITING +[01/May/2024:09:22:07] ENGINE Bus EXITED +[01/May/2024:09:22:07] ENGINE Waiting for child threads to terminate... +[01/May/2024:09:22:10] ENGINE Bus STARTING +[01/May/2024:09:22:10] ENGINE Started monitor thread 'Autoreloader'. +[01/May/2024:09:22:10] ENGINE Serving on http://0.0.0.0:8080 +[01/May/2024:09:22:10] ENGINE Bus STARTED +127.0.0.1 - - [01/May/2024:09:22:14] "GET /api/sequence/abbcc HTTP/1.1" 200 37 "" "PostmanRuntime/7.37.3" +[01/May/2024:09:22:18] ENGINE Keyboard Interrupt: shutting down bus +[01/May/2024:09:22:18] ENGINE Bus STOPPING +[01/May/2024:09:22:18] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 8080)) shut down +[01/May/2024:09:22:18] ENGINE Stopped thread 'Autoreloader'. +[01/May/2024:09:22:18] ENGINE Bus STOPPED +[01/May/2024:09:22:18] ENGINE Bus EXITING +[01/May/2024:09:22:18] ENGINE Bus EXITED +[01/May/2024:09:22:18] ENGINE Waiting for child threads to terminate... diff --git a/main_app.py b/main_app.py index a997712..d1c78a1 100644 --- a/main_app.py +++ b/main_app.py @@ -1,19 +1,19 @@ import cherrypy import os - +import sys from src.controller.sequence_controller import SequenceAPI - class Root(object): - @cherrypy.expose() + @cherrypy.expose def index(self): """ This function is going to return index.html files present in the static directory. - We don't need to implement it since it configured and cherrypy is going to handle it. + We don't need to implement it since it is configured and cherrypy is going to handle it. """ pass +def setup_server(port=8080): # Set up logging log_file = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'cherrypy.log') cherrypy.log.error_file = log_file @@ -22,32 +22,42 @@ def index(self): # Configure the global settings for CherryPy cherrypy.config.update({ 'server.socket_host': '0.0.0.0', - 'server.socket_port': 8080, + 'server.socket_port': port, 'log.error_file': log_file, 'log.screen': True, 'log.access_file': log_file }) + # Mount the ContactsAPI application + cherrypy.tree.mount(SequenceAPI(), '/api/sequence', { + '/': { + 'request.dispatch': cherrypy.dispatch.MethodDispatcher(), # Use method-based dispatching + 'tools.sessions.on': False, + 'tools.response_headers.on': True, + 'tools.response_headers.headers': [('Content-Type', 'text/plain')] + } + }) + + cherrypy.tree.mount(Root(), '/', { + '/': { + 'tools.staticdir.root': os.path.abspath(os.path.dirname(__file__)), + 'tools.staticdir.on': True, + 'tools.staticdir.dir': 'static', + 'tools.staticdir.index': 'index.html', + } + }) + + # Start the CherryPy server + cherrypy.engine.start() + cherrypy.engine.block() + +if __name__ == "__main__": + # Default port is 8080 unless specified + port = 8080 + if len(sys.argv) > 1: + try: + port = int(sys.argv[1]) + except ValueError: + print("Invalid port number. Using default port 8080.") -# Mount the ContactsAPI application -cherrypy.tree.mount(SequenceAPI(), '/api/sequence', { - '/': { - 'request.dispatch': cherrypy.dispatch.MethodDispatcher(), # Use method-based dispatching - 'tools.sessions.on': False, - 'tools.response_headers.on': True, - 'tools.response_headers.headers': [('Content-Type', 'text/plain')] - } -}) - -cherrypy.tree.mount(Root(), '/', { - '/': { - 'tools.staticdir.root': os.path.abspath(os.path.dirname(__file__)), - 'tools.staticdir.on': True, - 'tools.staticdir.dir': 'static', - 'tools.staticdir.index': 'index.html', - } -}) - -# Start the CherryPy server -cherrypy.engine.start() -cherrypy.engine.block() + setup_server(port) diff --git a/src/data/sequence_history.db b/src/data/sequence_history.db index 3b75bf2552e288cf14b18f7fa52ea4c41a661d9f..c34a471bff312f729286eed4073f04c7093b93f0 100644 GIT binary patch delta 192 zcmZojXh@hK&B!xR#+i|4W5N=CDQ>=74E*=_kMghLpTu9qpTO_Rugx#O_m%I~W<`NL zeD#vtEDYkhiAhPx$%f{JCZ;9^mc}M}Cg#S*hLT)Rsl;NKl%a{9v8jc*g(N42E<*#L tl!1}C1P4$`8`(e$3v)d)LklxWc63c9X6y!f76v9JhMN=Q=L;}$0|5OLEUW+k delta 46 zcmZojXh@hK&B#7c#+i|QW5N=C0XF^w2L5~eNBLLrPvWoQPuMJ|;KRQ;L4LjfBO3rZ C$_(!S diff --git a/src/data/store_sequence.db b/src/data/store_sequence.db index 0a36214..e76ecd6 100644 --- a/src/data/store_sequence.db +++ b/src/data/store_sequence.db @@ -28,3 +28,8 @@ Data inserted: money at 1714537009.1874113 Data inserted: HI at 1714538644.7882183 Data inserted: hi at 1714538649.6616385 Data inserted: abbcc at 1714539439.7597034 +Data inserted: abbcc at 1714540460.8044093 +Data inserted: abbcc at 1714540887.6186 +Data inserted: abbcc at 1714540910.3502722 +Data inserted: abbas at 1714540914.3587785 +Data inserted: abbcc at 1714540934.4733133 From dcb3e0b19d1ea1b731259e9cccbd603363446124 Mon Sep 17 00:00:00 2001 From: Abbas Tawfiq Ali Abdulrab <71519@omantel.om> Date: Wed, 1 May 2024 09:24:42 +0400 Subject: [PATCH 09/12] clear log --- cherrypy.log | 480 --------------------------------------------------- 1 file changed, 480 deletions(-) diff --git a/cherrypy.log b/cherrypy.log index 284c1d5..e69de29 100644 --- a/cherrypy.log +++ b/cherrypy.log @@ -1,480 +0,0 @@ -[29/Apr/2024:11:47:35] ENGINE Bus STARTING -[29/Apr/2024:11:47:35] ENGINE Started monitor thread 'Autoreloader'. -[29/Apr/2024:11:47:35] ENGINE Serving on http://0.0.0.0:8080 -[29/Apr/2024:11:47:35] ENGINE Bus STARTED -[29/Apr/2024:11:47:37] ENGINE Keyboard Interrupt: shutting down bus -[29/Apr/2024:11:47:37] ENGINE Bus STOPPING -[29/Apr/2024:11:47:37] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 8080)) shut down -[29/Apr/2024:11:47:37] ENGINE Stopped thread 'Autoreloader'. -[29/Apr/2024:11:47:37] ENGINE Bus STOPPED -[29/Apr/2024:11:47:37] ENGINE Bus EXITING -[29/Apr/2024:11:47:37] ENGINE Bus EXITED -[29/Apr/2024:11:47:37] ENGINE Waiting for child threads to terminate... -[29/Apr/2024:11:47:40] ENGINE Bus STARTING -[29/Apr/2024:11:47:40] ENGINE Started monitor thread 'Autoreloader'. -[29/Apr/2024:11:47:41] ENGINE Serving on http://0.0.0.0:8080 -[29/Apr/2024:11:47:41] ENGINE Bus STARTED -127.0.0.1 - - [29/Apr/2024:11:47:44] "GET /api/sequence HTTP/1.1" 200 151 "" "PostmanRuntime/7.37.3" -[29/Apr/2024:11:47:49] ENGINE Keyboard Interrupt: shutting down bus -[29/Apr/2024:11:47:49] ENGINE Bus STOPPING -[29/Apr/2024:11:47:49] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 8080)) shut down -[29/Apr/2024:11:47:49] ENGINE Stopped thread 'Autoreloader'. -[29/Apr/2024:11:47:49] ENGINE Bus STOPPED -[29/Apr/2024:11:47:49] ENGINE Bus EXITING -[29/Apr/2024:11:47:49] ENGINE Bus EXITED -[29/Apr/2024:11:47:49] ENGINE Waiting for child threads to terminate... -[29/Apr/2024:11:48:12] ENGINE Bus STARTING -[29/Apr/2024:11:48:12] ENGINE Started monitor thread 'Autoreloader'. -[29/Apr/2024:11:48:12] ENGINE Serving on http://0.0.0.0:8080 -[29/Apr/2024:11:48:12] ENGINE Bus STARTED -[29/Apr/2024:11:48:18] HTTP -Traceback (most recent call last): - File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\src\controller\sequence_controller.py", line 32, in GET - file_data = [seq.to_dict() for seq in sequencehistory.data] - ^^^^^^^^^^^^^ - File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\src\models\sequence.py", line 17, in to_dict - 'created_at': self.created_att - ^^^^^^^^^^^^^^^^ -AttributeError: 'Sequence' object has no attribute 'created_att'. Did you mean: 'created_at'? - -During handling of the above exception, another exception occurred: - -Traceback (most recent call last): - File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\.venv\Lib\site-packages\cherrypy\_cprequest.py", line 638, in respond - self._do_respond(path_info) - File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\.venv\Lib\site-packages\cherrypy\_cprequest.py", line 697, in _do_respond - response.body = self.handler() - ^^^^^^^^^^^^^^ - File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\.venv\Lib\site-packages\cherrypy\lib\encoding.py", line 223, in __call__ - self.body = self.oldhandler(*args, **kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\.venv\Lib\site-packages\cherrypy\lib\jsontools.py", line 59, in json_handler - value = cherrypy.serving.request._json_inner_handler(*args, **kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\.venv\Lib\site-packages\cherrypy\_cpdispatch.py", line 54, in __call__ - return self.callable(*self.args, **self.kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\src\controller\sequence_controller.py", line 35, in GET - print(traceback.format_exc(e)) - ^^^^^^^^^^^^^^^^^^^^^^^ - File "C:\Program Files\Python312\Lib\traceback.py", line 184, in format_exc - return "".join(format_exception(sys.exception(), limit=limit, chain=chain)) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "C:\Program Files\Python312\Lib\traceback.py", line 139, in format_exception - te = TracebackException(type(value), value, tb, limit=limit, compact=True) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "C:\Program Files\Python312\Lib\traceback.py", line 733, in __init__ - self.stack = StackSummary._extract_from_extended_frame_gen( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "C:\Program Files\Python312\Lib\traceback.py", line 411, in _extract_from_extended_frame_gen - if limit >= 0: - ^^^^^^^^^^ -TypeError: '>=' not supported between instances of 'AttributeError' and 'int' -[29/Apr/2024:11:48:18] HTTP -Request Headers: - Remote-Addr: 127.0.0.1 - USER-AGENT: PostmanRuntime/7.37.3 - ACCEPT: */* - POSTMAN-TOKEN: 286b7bfb-fddc-4889-b12e-7565ec4440aa - HOST: localhost:8080 - ACCEPT-ENCODING: gzip, deflate, br - CONNECTION: keep-alive -127.0.0.1 - - [29/Apr/2024:11:48:18] "GET /api/sequence HTTP/1.1" 500 3690 "" "PostmanRuntime/7.37.3" -[29/Apr/2024:11:48:41] ENGINE Keyboard Interrupt: shutting down bus -[29/Apr/2024:11:48:41] ENGINE Bus STOPPING -[29/Apr/2024:11:48:41] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 8080)) shut down -[29/Apr/2024:11:48:41] ENGINE Stopped thread 'Autoreloader'. -[29/Apr/2024:11:48:41] ENGINE Bus STOPPED -[29/Apr/2024:11:48:41] ENGINE Bus EXITING -[29/Apr/2024:11:48:41] ENGINE Bus EXITED -[29/Apr/2024:11:48:41] ENGINE Waiting for child threads to terminate... -[29/Apr/2024:11:50:17] ENGINE Bus STARTING -[29/Apr/2024:11:50:17] ENGINE Started monitor thread 'Autoreloader'. -[29/Apr/2024:11:50:17] ENGINE Serving on http://0.0.0.0:8080 -[29/Apr/2024:11:50:17] ENGINE Bus STARTED -127.0.0.1 - - [29/Apr/2024:11:50:25] "GET /api/sequence/aziz HTTP/1.1" 200 38 "" "PostmanRuntime/7.37.3" -127.0.0.1 - - [29/Apr/2024:11:51:01] "GET /api/sequence/dz_a_aazzaaa HTTP/1.1" 200 42 "" "PostmanRuntime/7.37.3" -127.0.0.1 - - [29/Apr/2024:11:51:08] "GET /api/sequence HTTP/1.1" 200 275 "" "PostmanRuntime/7.37.3" -[29/Apr/2024:11:51:23] ENGINE Keyboard Interrupt: shutting down bus -[29/Apr/2024:11:51:23] ENGINE Bus STOPPING -[29/Apr/2024:11:51:23] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 8080)) shut down -[29/Apr/2024:11:51:23] ENGINE Stopped thread 'Autoreloader'. -[29/Apr/2024:11:51:23] ENGINE Bus STOPPED -[29/Apr/2024:11:51:23] ENGINE Bus EXITING -[29/Apr/2024:11:51:23] ENGINE Bus EXITED -[29/Apr/2024:11:51:23] ENGINE Waiting for child threads to terminate... -[29/Apr/2024:11:52:50] ENGINE Bus STARTING -[29/Apr/2024:11:52:50] ENGINE Started monitor thread 'Autoreloader'. -[29/Apr/2024:11:52:50] ENGINE Serving on http://0.0.0.0:8080 -[29/Apr/2024:11:52:50] ENGINE Bus STARTED -127.0.0.1 - - [29/Apr/2024:11:53:00] "GET /api/sequence/ahmed HTTP/1.1" 200 37 "" "PostmanRuntime/7.37.3" -127.0.0.1 - - [29/Apr/2024:11:53:04] "GET /api/sequence HTTP/1.1" 200 340 "" "PostmanRuntime/7.37.3" -[29/Apr/2024:11:53:20] ENGINE Keyboard Interrupt: shutting down bus -[29/Apr/2024:11:53:20] ENGINE Bus STOPPING -[29/Apr/2024:11:53:20] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 8080)) shut down -[29/Apr/2024:11:53:20] ENGINE Stopped thread 'Autoreloader'. -[29/Apr/2024:11:53:20] ENGINE Bus STOPPED -[29/Apr/2024:11:53:20] ENGINE Bus EXITING -[29/Apr/2024:11:53:20] ENGINE Bus EXITED -[29/Apr/2024:11:53:20] ENGINE Waiting for child threads to terminate... -[29/Apr/2024:11:53:28] ENGINE Bus STARTING -[29/Apr/2024:11:53:28] ENGINE Started monitor thread 'Autoreloader'. -[29/Apr/2024:11:53:28] ENGINE Serving on http://0.0.0.0:8080 -[29/Apr/2024:11:53:28] ENGINE Bus STARTED -127.0.0.1 - - [29/Apr/2024:11:53:45] "GET /api/sequence/ahmed HTTP/1.1" 200 37 "" "PostmanRuntime/7.37.3" -[29/Apr/2024:11:54:09] ENGINE Keyboard Interrupt: shutting down bus -[29/Apr/2024:11:54:09] ENGINE Bus STOPPING -[29/Apr/2024:11:54:09] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 8080)) shut down -[29/Apr/2024:11:54:09] ENGINE Stopped thread 'Autoreloader'. -[29/Apr/2024:11:54:09] ENGINE Bus STOPPED -[29/Apr/2024:11:54:09] ENGINE Bus EXITING -[29/Apr/2024:11:54:09] ENGINE Bus EXITED -[29/Apr/2024:11:54:09] ENGINE Waiting for child threads to terminate... -[29/Apr/2024:13:22:24] ENGINE Bus STARTING -[29/Apr/2024:13:22:24] ENGINE Started monitor thread 'Autoreloader'. -[29/Apr/2024:13:22:24] ENGINE Serving on http://0.0.0.0:8080 -[29/Apr/2024:13:22:24] ENGINE Bus STARTED -127.0.0.1 - - [29/Apr/2024:13:22:57] "GET /api/sequence/ahmed HTTP/1.1" 200 37 "" "PostmanRuntime/7.37.3" -127.0.0.1 - - [29/Apr/2024:13:23:19] "GET /api/sequence/dzzzzaaaaa HTTP/1.1" 200 39 "" "PostmanRuntime/7.37.3" -127.0.0.1 - - [29/Apr/2024:13:23:24] "GET /api/sequence/dzzzzaaaaaa HTTP/1.1" 200 39 "" "PostmanRuntime/7.37.3" -[29/Apr/2024:13:23:33] HTTP -Traceback (most recent call last): - File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\src\controller\sequence_controller.py", line 31, in GET - sequencehistory = SequenceHistoryModel() - ^^^^^^^^^^^^^^^^^^^^^^ - File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\src\models\sequence_history.py", line 11, in __init__ - self.load_sequences() - File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\src\models\sequence_history.py", line 36, in load_sequences - sequences_from_db = self.fetch_sequences_from_db() - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\src\models\sequence_history.py", line 26, in fetch_sequences_from_db - cursor.execute("SELECT input_string, created_at FROM sequence_history") -sqlite3.OperationalError: no such table: sequence_history - -During handling of the above exception, another exception occurred: - -Traceback (most recent call last): - File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\.venv\Lib\site-packages\cherrypy\_cprequest.py", line 638, in respond - self._do_respond(path_info) - File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\.venv\Lib\site-packages\cherrypy\_cprequest.py", line 697, in _do_respond - response.body = self.handler() - ^^^^^^^^^^^^^^ - File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\.venv\Lib\site-packages\cherrypy\lib\encoding.py", line 223, in __call__ - self.body = self.oldhandler(*args, **kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\.venv\Lib\site-packages\cherrypy\lib\jsontools.py", line 59, in json_handler - value = cherrypy.serving.request._json_inner_handler(*args, **kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\.venv\Lib\site-packages\cherrypy\_cpdispatch.py", line 54, in __call__ - return self.callable(*self.args, **self.kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\src\controller\sequence_controller.py", line 35, in GET - print(traceback.format_exc(e)) - ^^^^^^^^^^^^^^^^^^^^^^^ - File "C:\Program Files\Python312\Lib\traceback.py", line 184, in format_exc - return "".join(format_exception(sys.exception(), limit=limit, chain=chain)) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "C:\Program Files\Python312\Lib\traceback.py", line 139, in format_exception - te = TracebackException(type(value), value, tb, limit=limit, compact=True) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "C:\Program Files\Python312\Lib\traceback.py", line 733, in __init__ - self.stack = StackSummary._extract_from_extended_frame_gen( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "C:\Program Files\Python312\Lib\traceback.py", line 411, in _extract_from_extended_frame_gen - if limit >= 0: - ^^^^^^^^^^ -TypeError: '>=' not supported between instances of 'OperationalError' and 'int' -[29/Apr/2024:13:23:33] HTTP -Request Headers: - Remote-Addr: 127.0.0.1 - USER-AGENT: PostmanRuntime/7.37.3 - ACCEPT: */* - POSTMAN-TOKEN: 221889de-b550-4a77-a5ef-c9cf3ccc1ef8 - HOST: localhost:8080 - ACCEPT-ENCODING: gzip, deflate, br - CONNECTION: keep-alive -127.0.0.1 - - [29/Apr/2024:13:23:33] "GET /api/sequence HTTP/1.1" 500 4061 "" "PostmanRuntime/7.37.3" -[29/Apr/2024:13:24:06] ENGINE Keyboard Interrupt: shutting down bus -[29/Apr/2024:13:24:06] ENGINE Bus STOPPING -[29/Apr/2024:13:24:07] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 8080)) shut down -[29/Apr/2024:13:24:07] ENGINE Stopped thread 'Autoreloader'. -[29/Apr/2024:13:24:07] ENGINE Bus STOPPED -[29/Apr/2024:13:24:07] ENGINE Bus EXITING -[29/Apr/2024:13:24:07] ENGINE Bus EXITED -[29/Apr/2024:13:24:07] ENGINE Waiting for child threads to terminate... -[29/Apr/2024:13:24:32] ENGINE Bus STARTING -[29/Apr/2024:13:24:32] ENGINE Started monitor thread 'Autoreloader'. -[29/Apr/2024:13:24:32] ENGINE Serving on http://0.0.0.0:8080 -[29/Apr/2024:13:24:32] ENGINE Bus STARTED -[29/Apr/2024:13:24:37] HTTP -Traceback (most recent call last): - File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\src\controller\sequence_controller.py", line 31, in GET - sequencehistory = SequenceHistoryModel() - ^^^^^^^^^^^^^^^^^^^^^^ - File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\src\models\sequence_history.py", line 11, in __init__ - self.load_sequences() - File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\src\models\sequence_history.py", line 36, in load_sequences - sequences_from_db = self.fetch_sequences_from_db() - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\src\models\sequence_history.py", line 26, in fetch_sequences_from_db - cursor.execute("SELECT input_string, created_at FROM sequence_history") -sqlite3.OperationalError: no such table: sequence_history - -During handling of the above exception, another exception occurred: - -Traceback (most recent call last): - File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\.venv\Lib\site-packages\cherrypy\_cprequest.py", line 638, in respond - self._do_respond(path_info) - File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\.venv\Lib\site-packages\cherrypy\_cprequest.py", line 697, in _do_respond - response.body = self.handler() - ^^^^^^^^^^^^^^ - File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\.venv\Lib\site-packages\cherrypy\lib\encoding.py", line 223, in __call__ - self.body = self.oldhandler(*args, **kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\.venv\Lib\site-packages\cherrypy\lib\jsontools.py", line 59, in json_handler - value = cherrypy.serving.request._json_inner_handler(*args, **kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\.venv\Lib\site-packages\cherrypy\_cpdispatch.py", line 54, in __call__ - return self.callable(*self.args, **self.kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\src\controller\sequence_controller.py", line 35, in GET - print(traceback.format_exc(e)) - ^^^^^^^^^^^^^^^^^^^^^^^ - File "C:\Program Files\Python312\Lib\traceback.py", line 184, in format_exc - return "".join(format_exception(sys.exception(), limit=limit, chain=chain)) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "C:\Program Files\Python312\Lib\traceback.py", line 139, in format_exception - te = TracebackException(type(value), value, tb, limit=limit, compact=True) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "C:\Program Files\Python312\Lib\traceback.py", line 733, in __init__ - self.stack = StackSummary._extract_from_extended_frame_gen( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "C:\Program Files\Python312\Lib\traceback.py", line 411, in _extract_from_extended_frame_gen - if limit >= 0: - ^^^^^^^^^^ -TypeError: '>=' not supported between instances of 'OperationalError' and 'int' -[29/Apr/2024:13:24:37] HTTP -Request Headers: - Remote-Addr: 127.0.0.1 - USER-AGENT: PostmanRuntime/7.37.3 - ACCEPT: */* - POSTMAN-TOKEN: 260e7b26-2d1f-4430-b6d6-745da750c454 - HOST: localhost:8080 - ACCEPT-ENCODING: gzip, deflate, br - CONNECTION: keep-alive -127.0.0.1 - - [29/Apr/2024:13:24:37] "GET /api/sequence HTTP/1.1" 500 4061 "" "PostmanRuntime/7.37.3" -127.0.0.1 - - [29/Apr/2024:13:24:42] "GET /api/sequence/abbas HTTP/1.1" 200 38 "" "PostmanRuntime/7.37.3" -127.0.0.1 - - [29/Apr/2024:13:24:47] "GET /api/sequence HTTP/1.1" 200 92 "" "PostmanRuntime/7.37.3" -[29/Apr/2024:13:25:04] ENGINE Keyboard Interrupt: shutting down bus -[29/Apr/2024:13:25:04] ENGINE Bus STOPPING -[29/Apr/2024:13:25:04] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 8080)) shut down -[29/Apr/2024:13:25:04] ENGINE Stopped thread 'Autoreloader'. -[29/Apr/2024:13:25:04] ENGINE Bus STOPPED -[29/Apr/2024:13:25:04] ENGINE Bus EXITING -[29/Apr/2024:13:25:04] ENGINE Bus EXITED -[29/Apr/2024:13:25:04] ENGINE Waiting for child threads to terminate... -[29/Apr/2024:13:29:06] ENGINE Bus STARTING -[29/Apr/2024:13:29:06] ENGINE Started monitor thread 'Autoreloader'. -[29/Apr/2024:13:29:06] ENGINE Serving on http://0.0.0.0:8080 -[29/Apr/2024:13:29:06] ENGINE Bus STARTED -[29/Apr/2024:13:29:08] HTTP -Traceback (most recent call last): - File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\src\controller\sequence_controller.py", line 31, in GET - sequencehistory = SequenceHistoryModel() - ^^^^^^^^^^^^^^^^^^^^^^ - File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\src\models\sequence_history.py", line 11, in __init__ - self.load_sequences() - File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\src\models\sequence_history.py", line 42, in load_sequences - for seq in sequences_from_db: -TypeError: 'NoneType' object is not iterable - -During handling of the above exception, another exception occurred: - -Traceback (most recent call last): - File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\.venv\Lib\site-packages\cherrypy\_cprequest.py", line 638, in respond - self._do_respond(path_info) - File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\.venv\Lib\site-packages\cherrypy\_cprequest.py", line 697, in _do_respond - response.body = self.handler() - ^^^^^^^^^^^^^^ - File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\.venv\Lib\site-packages\cherrypy\lib\encoding.py", line 223, in __call__ - self.body = self.oldhandler(*args, **kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\.venv\Lib\site-packages\cherrypy\lib\jsontools.py", line 59, in json_handler - value = cherrypy.serving.request._json_inner_handler(*args, **kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\.venv\Lib\site-packages\cherrypy\_cpdispatch.py", line 54, in __call__ - return self.callable(*self.args, **self.kwargs) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "C:\Users\71519\Documents\PackageMeasurementConversionAPI\src\controller\sequence_controller.py", line 35, in GET - print(traceback.format_exc(e)) - ^^^^^^^^^^^^^^^^^^^^^^^ - File "C:\Program Files\Python312\Lib\traceback.py", line 184, in format_exc - return "".join(format_exception(sys.exception(), limit=limit, chain=chain)) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "C:\Program Files\Python312\Lib\traceback.py", line 139, in format_exception - te = TracebackException(type(value), value, tb, limit=limit, compact=True) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "C:\Program Files\Python312\Lib\traceback.py", line 733, in __init__ - self.stack = StackSummary._extract_from_extended_frame_gen( - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "C:\Program Files\Python312\Lib\traceback.py", line 411, in _extract_from_extended_frame_gen - if limit >= 0: - ^^^^^^^^^^ -TypeError: '>=' not supported between instances of 'TypeError' and 'int' -[29/Apr/2024:13:29:09] HTTP -Request Headers: - Remote-Addr: 127.0.0.1 - USER-AGENT: PostmanRuntime/7.37.3 - ACCEPT: */* - POSTMAN-TOKEN: 403e7db1-4799-4ea3-9ee4-031d650d70f5 - HOST: localhost:8080 - ACCEPT-ENCODING: gzip, deflate, br - CONNECTION: keep-alive -127.0.0.1 - - [29/Apr/2024:13:29:09] "GET /api/sequence HTTP/1.1" 500 3755 "" "PostmanRuntime/7.37.3" -[29/Apr/2024:13:29:28] ENGINE Keyboard Interrupt: shutting down bus -[29/Apr/2024:13:29:28] ENGINE Bus STOPPING -[29/Apr/2024:13:29:28] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 8080)) shut down -[29/Apr/2024:13:29:28] ENGINE Stopped thread 'Autoreloader'. -[29/Apr/2024:13:29:28] ENGINE Bus STOPPED -[29/Apr/2024:13:29:28] ENGINE Bus EXITING -[29/Apr/2024:13:29:28] ENGINE Bus EXITED -[29/Apr/2024:13:29:28] ENGINE Waiting for child threads to terminate... -[29/Apr/2024:13:29:57] ENGINE Bus STARTING -[29/Apr/2024:13:29:57] ENGINE Started monitor thread 'Autoreloader'. -[29/Apr/2024:13:29:57] ENGINE Serving on http://0.0.0.0:8080 -[29/Apr/2024:13:29:57] ENGINE Bus STARTED -127.0.0.1 - - [29/Apr/2024:13:30:00] "GET /api/sequence HTTP/1.1" 200 33 "" "PostmanRuntime/7.37.3" -[29/Apr/2024:13:30:17] ENGINE Keyboard Interrupt: shutting down bus -[29/Apr/2024:13:30:17] ENGINE Bus STOPPING -[29/Apr/2024:13:30:18] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 8080)) shut down -[29/Apr/2024:13:30:18] ENGINE Stopped thread 'Autoreloader'. -[29/Apr/2024:13:30:18] ENGINE Bus STOPPED -[29/Apr/2024:13:30:18] ENGINE Bus EXITING -[29/Apr/2024:13:30:18] ENGINE Bus EXITED -[29/Apr/2024:13:30:18] ENGINE Waiting for child threads to terminate... -[29/Apr/2024:13:30:24] ENGINE Bus STARTING -[29/Apr/2024:13:30:24] ENGINE Started monitor thread 'Autoreloader'. -[29/Apr/2024:13:30:25] ENGINE Serving on http://0.0.0.0:8080 -[29/Apr/2024:13:30:25] ENGINE Bus STARTED -127.0.0.1 - - [29/Apr/2024:13:30:26] "GET /api/sequence HTTP/1.1" 200 33 "" "PostmanRuntime/7.37.3" -[29/Apr/2024:13:30:34] ENGINE Keyboard Interrupt: shutting down bus -[29/Apr/2024:13:30:34] ENGINE Bus STOPPING -[29/Apr/2024:13:30:35] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 8080)) shut down -[29/Apr/2024:13:30:35] ENGINE Stopped thread 'Autoreloader'. -[29/Apr/2024:13:30:35] ENGINE Bus STOPPED -[29/Apr/2024:13:30:35] ENGINE Bus EXITING -[29/Apr/2024:13:30:35] ENGINE Bus EXITED -[29/Apr/2024:13:30:35] ENGINE Waiting for child threads to terminate... -[29/Apr/2024:13:30:38] ENGINE Bus STARTING -[29/Apr/2024:13:30:38] ENGINE Started monitor thread 'Autoreloader'. -[29/Apr/2024:13:30:38] ENGINE Serving on http://0.0.0.0:8080 -[29/Apr/2024:13:30:38] ENGINE Bus STARTED -127.0.0.1 - - [29/Apr/2024:13:30:58] "GET /api/sequence/dz_a_aazzaaa HTTP/1.1" 200 42 "" "PostmanRuntime/7.37.3" -127.0.0.1 - - [29/Apr/2024:13:31:02] "GET /api/sequence HTTP/1.1" 200 98 "" "PostmanRuntime/7.37.3" -[29/Apr/2024:13:34:02] ENGINE Keyboard Interrupt: shutting down bus -[29/Apr/2024:13:34:02] ENGINE Bus STOPPING -[29/Apr/2024:13:34:02] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 8080)) shut down -[29/Apr/2024:13:34:02] ENGINE Stopped thread 'Autoreloader'. -[29/Apr/2024:13:34:02] ENGINE Bus STOPPED -[29/Apr/2024:13:34:02] ENGINE Bus EXITING -[29/Apr/2024:13:34:02] ENGINE Bus EXITED -[29/Apr/2024:13:34:02] ENGINE Waiting for child threads to terminate... -[01/May/2024:08:15:30] ENGINE Bus STARTING -[01/May/2024:08:15:30] ENGINE Started monitor thread 'Autoreloader'. -[01/May/2024:08:15:31] ENGINE Serving on http://0.0.0.0:8080 -[01/May/2024:08:15:31] ENGINE Bus STARTED -127.0.0.1 - - [01/May/2024:08:16:11] "GET /api/sequence HTTP/1.1" 200 99 "" "PostmanRuntime/7.37.3" -127.0.0.1 - - [01/May/2024:08:16:24] "GET /api/sequence/hhh HTTP/1.1" 200 35 "" "PostmanRuntime/7.37.3" -127.0.0.1 - - [01/May/2024:08:16:29] "GET /api/sequence HTTP/1.1" 200 158 "" "PostmanRuntime/7.37.3" -127.0.0.1 - - [01/May/2024:08:16:49] "GET /api/sequence/money HTTP/1.1" 200 35 "" "PostmanRuntime/7.37.3" -[01/May/2024:08:16:55] ENGINE Keyboard Interrupt: shutting down bus -[01/May/2024:08:16:55] ENGINE Bus STOPPING -[01/May/2024:08:16:55] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 8080)) shut down -[01/May/2024:08:16:55] ENGINE Stopped thread 'Autoreloader'. -[01/May/2024:08:16:55] ENGINE Bus STOPPED -[01/May/2024:08:16:55] ENGINE Bus EXITING -[01/May/2024:08:16:55] ENGINE Bus EXITED -[01/May/2024:08:16:55] ENGINE Waiting for child threads to terminate... -[01/May/2024:08:43:53] ENGINE Bus STARTING -[01/May/2024:08:43:53] ENGINE Started monitor thread 'Autoreloader'. -[01/May/2024:08:43:53] ENGINE Serving on http://0.0.0.0:8080 -[01/May/2024:08:43:53] ENGINE Bus STARTED -127.0.0.1 - - [01/May/2024:08:43:56] "GET /api/sequence HTTP/1.1" 200 219 "" "PostmanRuntime/7.37.3" -127.0.0.1 - - [01/May/2024:08:44:04] "GET /api/sequence/HI HTTP/1.1" 200 33 "" "PostmanRuntime/7.37.3" -127.0.0.1 - - [01/May/2024:08:44:09] "GET /api/sequence/hi HTTP/1.1" 200 34 "" "PostmanRuntime/7.37.3" -127.0.0.1 - - [01/May/2024:08:44:15] "GET /api/sequence HTTP/1.1" 200 335 "" "PostmanRuntime/7.37.3" -[01/May/2024:08:44:36] ENGINE Keyboard Interrupt: shutting down bus -[01/May/2024:08:44:36] ENGINE Bus STOPPING -[01/May/2024:08:44:36] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 8080)) shut down -[01/May/2024:08:44:36] ENGINE Stopped thread 'Autoreloader'. -[01/May/2024:08:44:36] ENGINE Bus STOPPED -[01/May/2024:08:44:36] ENGINE Bus EXITING -[01/May/2024:08:44:36] ENGINE Bus EXITED -[01/May/2024:08:44:36] ENGINE Waiting for child threads to terminate... -[01/May/2024:08:56:31] ENGINE Bus STARTING -[01/May/2024:08:56:31] ENGINE Started monitor thread 'Autoreloader'. -[01/May/2024:08:56:32] ENGINE Serving on http://0.0.0.0:8080 -[01/May/2024:08:56:32] ENGINE Bus STARTED -127.0.0.1 - - [01/May/2024:08:57:06] "GET /api/sequence HTTP/1.1" 200 330 "" "PostmanRuntime/7.37.3" -127.0.0.1 - - [01/May/2024:08:57:19] "GET /api/sequence/abbcc HTTP/1.1" 200 37 "" "PostmanRuntime/7.37.3" -[01/May/2024:08:57:27] ENGINE Keyboard Interrupt: shutting down bus -[01/May/2024:08:57:27] ENGINE Bus STOPPING -[01/May/2024:08:57:27] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 8080)) shut down -[01/May/2024:08:57:27] ENGINE Stopped thread 'Autoreloader'. -[01/May/2024:08:57:27] ENGINE Bus STOPPED -[01/May/2024:08:57:27] ENGINE Bus EXITING -[01/May/2024:08:57:27] ENGINE Bus EXITED -[01/May/2024:08:57:27] ENGINE Waiting for child threads to terminate... -[01/May/2024:09:14:16] ENGINE Bus STARTING -[01/May/2024:09:14:16] ENGINE Started monitor thread 'Autoreloader'. -[01/May/2024:09:14:16] ENGINE Serving on http://0.0.0.0:8080 -[01/May/2024:09:14:16] ENGINE Bus STARTED -127.0.0.1 - - [01/May/2024:09:14:20] "GET /api/sequence/abbcc HTTP/1.1" 200 37 "" "PostmanRuntime/7.37.3" -[01/May/2024:09:17:55] ENGINE Keyboard Interrupt: shutting down bus -[01/May/2024:09:17:55] ENGINE Bus STOPPING -[01/May/2024:09:17:55] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 8080)) shut down -[01/May/2024:09:17:55] ENGINE Stopped thread 'Autoreloader'. -[01/May/2024:09:17:55] ENGINE Bus STOPPED -[01/May/2024:09:17:55] ENGINE Bus EXITING -[01/May/2024:09:17:55] ENGINE Bus EXITED -[01/May/2024:09:17:55] ENGINE Waiting for child threads to terminate... -[01/May/2024:09:21:21] ENGINE Bus STARTING -[01/May/2024:09:21:21] ENGINE Started monitor thread 'Autoreloader'. -[01/May/2024:09:21:22] ENGINE Serving on http://0.0.0.0:8080 -[01/May/2024:09:21:22] ENGINE Bus STARTED -127.0.0.1 - - [01/May/2024:09:21:27] "GET /api/sequence/abbcc HTTP/1.1" 200 37 "" "PostmanRuntime/7.37.3" -[01/May/2024:09:21:30] ENGINE Keyboard Interrupt: shutting down bus -[01/May/2024:09:21:30] ENGINE Bus STOPPING -[01/May/2024:09:21:30] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 8080)) shut down -[01/May/2024:09:21:30] ENGINE Stopped thread 'Autoreloader'. -[01/May/2024:09:21:30] ENGINE Bus STOPPED -[01/May/2024:09:21:30] ENGINE Bus EXITING -[01/May/2024:09:21:30] ENGINE Bus EXITED -[01/May/2024:09:21:30] ENGINE Waiting for child threads to terminate... -[01/May/2024:09:21:42] ENGINE Bus STARTING -[01/May/2024:09:21:42] ENGINE Started monitor thread 'Autoreloader'. -[01/May/2024:09:21:42] ENGINE Serving on http://0.0.0.0:8888 -[01/May/2024:09:21:42] ENGINE Bus STARTED -127.0.0.1 - - [01/May/2024:09:21:50] "GET /api/sequence/abbcc HTTP/1.1" 200 37 "" "PostmanRuntime/7.37.3" -127.0.0.1 - - [01/May/2024:09:21:54] "GET /api/sequence/abbas HTTP/1.1" 200 38 "" "PostmanRuntime/7.37.3" -[01/May/2024:09:22:07] ENGINE Keyboard Interrupt: shutting down bus -[01/May/2024:09:22:07] ENGINE Bus STOPPING -[01/May/2024:09:22:07] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 8888)) shut down -[01/May/2024:09:22:07] ENGINE Stopped thread 'Autoreloader'. -[01/May/2024:09:22:07] ENGINE Bus STOPPED -[01/May/2024:09:22:07] ENGINE Bus EXITING -[01/May/2024:09:22:07] ENGINE Bus EXITED -[01/May/2024:09:22:07] ENGINE Waiting for child threads to terminate... -[01/May/2024:09:22:10] ENGINE Bus STARTING -[01/May/2024:09:22:10] ENGINE Started monitor thread 'Autoreloader'. -[01/May/2024:09:22:10] ENGINE Serving on http://0.0.0.0:8080 -[01/May/2024:09:22:10] ENGINE Bus STARTED -127.0.0.1 - - [01/May/2024:09:22:14] "GET /api/sequence/abbcc HTTP/1.1" 200 37 "" "PostmanRuntime/7.37.3" -[01/May/2024:09:22:18] ENGINE Keyboard Interrupt: shutting down bus -[01/May/2024:09:22:18] ENGINE Bus STOPPING -[01/May/2024:09:22:18] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 8080)) shut down -[01/May/2024:09:22:18] ENGINE Stopped thread 'Autoreloader'. -[01/May/2024:09:22:18] ENGINE Bus STOPPED -[01/May/2024:09:22:18] ENGINE Bus EXITING -[01/May/2024:09:22:18] ENGINE Bus EXITED -[01/May/2024:09:22:18] ENGINE Waiting for child threads to terminate... From e5e1b3649f9ee203f4df01fd1401fc37537d6d20 Mon Sep 17 00:00:00 2001 From: Abbas Tawfiq Ali Abdulrab <71519@omantel.om> Date: Wed, 1 May 2024 10:03:12 +0400 Subject: [PATCH 10/12] refactoring --- main_app.py | 3 +++ src/controller/sequence_controller.py | 4 ++-- src/data/sequence_history.db | Bin 12288 -> 12288 bytes src/data/store_sequence.db | 8 ++++++++ src/services/sequence_service.py | 4 ++-- .../test_sequence_processor.cpython-312.pyc | Bin 1819 -> 0 bytes src/{models => utils}/sequence_history.py | 0 7 files changed, 15 insertions(+), 4 deletions(-) delete mode 100644 src/services/unittest/__pycache__/test_sequence_processor.cpython-312.pyc rename src/{models => utils}/sequence_history.py (100%) diff --git a/main_app.py b/main_app.py index d1c78a1..014c65c 100644 --- a/main_app.py +++ b/main_app.py @@ -4,6 +4,7 @@ from src.controller.sequence_controller import SequenceAPI + class Root(object): @cherrypy.expose def index(self): @@ -13,6 +14,7 @@ def index(self): """ pass + def setup_server(port=8080): # Set up logging log_file = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'cherrypy.log') @@ -51,6 +53,7 @@ def setup_server(port=8080): cherrypy.engine.start() cherrypy.engine.block() + if __name__ == "__main__": # Default port is 8080 unless specified port = 8080 diff --git a/src/controller/sequence_controller.py b/src/controller/sequence_controller.py index 8554995..c5dfd39 100644 --- a/src/controller/sequence_controller.py +++ b/src/controller/sequence_controller.py @@ -5,7 +5,7 @@ from src.services.sequence_service import SequenceService from src.utils.File_Handler import FileHandler from src.services.sequence_processor import SequenceProcessor -from src.models.sequence_history import SequenceHistoryModel +from src.utils.sequence_history import SequenceHistoryModel class SequenceAPI(object): @@ -25,7 +25,7 @@ def GET(self, input_string: str = ""): processed_results = processor.create_result() res_msg = {"status": "SUCCESS", "data": processed_results} - sequence.process_and_store_string(input_string) + sequence.input_service(input_string) else: sequencehistory = SequenceHistoryModel() diff --git a/src/data/sequence_history.db b/src/data/sequence_history.db index c34a471bff312f729286eed4073f04c7093b93f0..f8f5842efaa8f9d92b119462a122fb2ed3116565 100644 GIT binary patch delta 300 zcmZojXh@hK%_uTa#+gxMW5N=CEn(j84E*=_kMghLpTu9qpTO_Rugx#O_m%G!-+sQu zd~JLge7<}}eB!*{Hx{1ct(OyKVNldfsftg807G*_6H^moBTF+qGXpboV@V+v265fQ zjNH@|n3SQJo{6QonW>~8SSl$gITAf{eldxfVy& delta 56 zc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((?(G*gq9 zPN`g}ieoj&YmHg2mfx>QKI=m(TAu%#D~MyM<#1nKImWby7Y(u diff --git a/src/models/sequence_history.py b/src/utils/sequence_history.py similarity index 100% rename from src/models/sequence_history.py rename to src/utils/sequence_history.py From 032d2ed595a969fe14ab42c1a31d44acb1ddd1e0 Mon Sep 17 00:00:00 2001 From: Abbas Tawfiq Ali Abdulrab <71519@omantel.om> Date: Wed, 1 May 2024 11:54:31 +0400 Subject: [PATCH 11/12] datetime view --- src/data/sequence_history.db | Bin 12288 -> 12288 bytes src/data/store_sequence.db | 4 ++++ src/models/sequence.py | 6 +++--- src/utils/sequence_history.py | 8 ++++---- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/data/sequence_history.db b/src/data/sequence_history.db index f8f5842efaa8f9d92b119462a122fb2ed3116565..3ae757222ee745f45717990a9e3b263301759f26 100644 GIT binary patch delta 142 zcmZojXh@hK%_uQZ#+gxKW5N=CW^vxi$?O8^9K2U~cks^Ut=w4X%*&)8KKX&Xh=-|( zrKORvp1F~Qk+HNG3xl+7Mq*}3Mq;j^xuJ=viJ7svrJkvok)g4)D5j*LnVFuknYp>K bf(Xbk9-w*y14BIvLsL_u&EI7?gc!vEK4K#u delta 36 scmZojXh@hK%_uTa#+gxMW5N=CW?|m%li3B-Hx{1c-TYmaLx@or0Mk(mA^-pY diff --git a/src/data/store_sequence.db b/src/data/store_sequence.db index 7393a32..16f46fe 100644 --- a/src/data/store_sequence.db +++ b/src/data/store_sequence.db @@ -41,3 +41,7 @@ Data inserted: abbcc at 1714541479.1183517 Data inserted: abbcc at 1714543211.425924 Data inserted: ahmed at 1714543216.4976542 Data inserted: dz_aaaaaaa at 1714543296.6067295 +Data inserted: dz_a_aazzaaa at 1714546001.8155222 +Data inserted: haitham at 1714546166.3677306 +Data inserted: haitham at 1714546379.5621347 +Data inserted: dz_a_aazzaaa at 1714549923.728234 diff --git a/src/models/sequence.py b/src/models/sequence.py index e8180b0..083f0c1 100644 --- a/src/models/sequence.py +++ b/src/models/sequence.py @@ -3,9 +3,9 @@ class Sequence: - def __init__(self, input_string): + def __init__(self, input_string, created_at_epoch_time=time.time()): self.input_string = input_string - self.created_at = time.time() + self.created_at = created_at_epoch_time def get_string(self): return self.input_string @@ -15,4 +15,4 @@ def to_dict(self): return { 'input_string': self.input_string, 'created_at': self.created_at - } \ No newline at end of file + } diff --git a/src/utils/sequence_history.py b/src/utils/sequence_history.py index 8923adc..03ab12e 100644 --- a/src/utils/sequence_history.py +++ b/src/utils/sequence_history.py @@ -2,6 +2,7 @@ import sqlite3 +from datetime import datetime class SequenceHistoryModel: @@ -27,7 +28,8 @@ def fetch_sequences_from_db(self): cursor.execute("SELECT input_string, created_at FROM sequence_history") rows = cursor.fetchall() for row in rows: - sequences.append({'input_string': row[0], 'created_at': row[1]}) + formatted = datetime.fromtimestamp(float(row[1])).strftime("%Y-%m-%d %H:%M:%S") + sequences.append({'input_string': row[0], 'created_at': formatted}) return sequences except FileNotFoundError as file: print("File Not found") @@ -41,9 +43,7 @@ def load_sequences(self): try: sequences_from_db = self.fetch_sequences_from_db() for seq in sequences_from_db: - # Assuming Sequence class now has a method or way to also store processed time - sequence = Sequence(seq['input_string']) - sequence.processed_time = seq['created_at'] # Dynamically add processed time if not in constructor + sequence = Sequence(seq['input_string'], seq['created_at']) self.data.append(sequence) except Exception as ex: print("Error", ex) From 255f77dc794c2cbdc3b4ba89833efd2f03cf74ab Mon Sep 17 00:00:00 2001 From: Abbas Tawfiq Ali Abdulrab <71519@omantel.om> Date: Thu, 2 May 2024 10:05:20 +0400 Subject: [PATCH 12/12] fixed special case handling --- src/controller/sequence_controller.py | 6 ++-- src/data/sequence_history.db | Bin 12288 -> 0 bytes src/data/store_sequence.db | 47 -------------------------- src/services/sequence_processor.py | 7 ++-- 4 files changed, 8 insertions(+), 52 deletions(-) delete mode 100644 src/data/sequence_history.db diff --git a/src/controller/sequence_controller.py b/src/controller/sequence_controller.py index c5dfd39..5868620 100644 --- a/src/controller/sequence_controller.py +++ b/src/controller/sequence_controller.py @@ -13,7 +13,7 @@ class SequenceAPI(object): @cherrypy.tools.json_out() def GET(self, input_string: str = ""): - res_msg = {"status": "FAIL", "data": []} + res_msg = {"status": "FAIL", "result": []} storage_type = "db" file_handler = FileHandler(storage_type) sequence = SequenceService(storage_type) @@ -24,13 +24,13 @@ def GET(self, input_string: str = ""): processor = SequenceProcessor(string_instance) processed_results = processor.create_result() - res_msg = {"status": "SUCCESS", "data": processed_results} + res_msg = {"status": "SUCCESS", "err_msg": "", "result": processed_results} sequence.input_service(input_string) else: sequencehistory = SequenceHistoryModel() file_data = [seq.to_dict() for seq in sequencehistory.data] - res_msg = {"status": "SUCCESS", "data": file_data} + res_msg = {"status": "SUCCESS", "err_msg": "", "result": file_data} except Exception as e: print(traceback.format_exc(e)) res_msg = {"status": "fail", "err_msg": "invalid sequence", "result": []} diff --git a/src/data/sequence_history.db b/src/data/sequence_history.db deleted file mode 100644 index 3ae757222ee745f45717990a9e3b263301759f26..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI&Pfrs;6aes9SV7V5f*@r<&3Z6_Kqospv-9U>H5+XNM68LN>QGj<2`xg)p}pzB z58&0KH$Q=%Jel|fym;^fcsE|1r7eb1qlqVz_tI@U`)1zT`K6ah`r!U*t(Evs_73X0 zgS<#>iNHdD+@(>FwR5xxZ@;wUuVFf0#6?gTv8Vn{lxm`{m-z)z}}H zyV%h6WW}spdS120^M!)-qTQ|8D^^Ks&DP#QyI;IN9ywWcV79+F;SY)0j$c|Y$G786 ze`B+>R@~h3@5Wnx@nQL1Y26fDi`UC5!&f$*9kwdX)%MY3?qfH0m)%L{yYt2Q;Jk5OI;pefgib#9BlkJ?F8A6@ zhX4T(009sH0T2KI5C8!X009vATLC|Bqw9s8PDNL=?sT-)L=YA+r9z5DC_}n1Yomoi zs%x!O*Skqhg~AaJ30=5!I!QRklnX)qnc=m05D+X$6opr(ZFKFZyJ>vfn}&*G9&kau zi#Ey^bXre#x}9lAIA%)l$eTJ!ZEshr$0>qY7^%>k97qvno|h0wqsy+1uJjtVds{Wz zjc^c!0a50k=IN1bBy6oN~OFDr#e!GIaNe>=Lb@OGASk~ zCEi3YrJLP?fg%jkNDAqlJGF`gCKZHY?yN~I>t7oWq!gGF$-VKxMT`en28@xpv6G9a zVpL%fDKUG-MpK2fcJu^Pa;7lngtJ*YyML#2e4k+ 0 and i + 1 < len(combined_list): + if count + i + 1 > len(combined_list): + self.results = [] + break + elif count > 0 and i + 1 < len(combined_list): sum_sequence = sum(combined_list[i + 1:i + 1 + count]) self.append_result(sum_sequence) i += count + 1 @@ -97,7 +100,7 @@ def create_result(self): # Example usage if __name__ == "__main__": test_strings = [ - 'abbcc', 'dz_a_aazzaaa', 'a_', 'abcdabcdab', 'abcdabcdab_', + 'aaa', 'dz_a_aazzaaa', 'a_', 'abcdabcdab', 'abcdabcdab_', 'zdaaaaaaaabaaaaaaaabaaaaaaaabbaa', 'zza_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_', 'za_a_a_a_a_a_a_a_a_a_a_a_a_azaaa', '_a', '_', '_ad', '_zzzb', '__'