Spaces:
Sleeping
Sleeping
lakshmi324
commited on
Commit
·
3969bc0
1
Parent(s):
1c8156a
intital commit
Browse files- app.py +99 -0
- requirements.txt +2 -0
app.py
ADDED
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pandas as pd
|
2 |
+
import ast
|
3 |
+
import os
|
4 |
+
import gradio as gr
|
5 |
+
|
6 |
+
|
7 |
+
class airpods(object):
|
8 |
+
|
9 |
+
def __init__(self,master,input_model,input_charging_case_serial,input_box_serial_number,input_leftbud_model,input_rightbud_model,input_leftbud_serial,input_rightbud_serial,input_firmware):
|
10 |
+
'''
|
11 |
+
'''
|
12 |
+
self.master = master
|
13 |
+
self.input_model = input_model
|
14 |
+
self.input_charging_case_serial = input_charging_case_serial
|
15 |
+
self.input_box_serial_number = input_box_serial_number
|
16 |
+
self.input_leftbud_model = input_leftbud_model
|
17 |
+
self.input_rightbud_model = input_rightbud_model
|
18 |
+
self.input_leftbud_serial = input_leftbud_serial
|
19 |
+
self.input_rightbud_serial = input_rightbud_serial
|
20 |
+
self.input_firmware = input_firmware
|
21 |
+
|
22 |
+
|
23 |
+
def Iterative_Serial_Check(self):
|
24 |
+
'''
|
25 |
+
Function checks if the airbuds serial numbers are iterative
|
26 |
+
'''
|
27 |
+
string = self.input_leftbud_serial[-1] + self.input_rightbud_serial[-1] + self.input_charging_case_serial[-1]
|
28 |
+
string = string.lower()
|
29 |
+
return not any(m > n for m,n in zip(string,string[1:]))
|
30 |
+
|
31 |
+
def check_latest_firmware(self):
|
32 |
+
'''
|
33 |
+
Function to check if the airbuds are on the latest firmware
|
34 |
+
'''
|
35 |
+
return (self.master[self.input_model]['firmware'] == self.input_firmware)
|
36 |
+
|
37 |
+
def check_matching_serial(self):
|
38 |
+
'''
|
39 |
+
Function to check if the airbuds are having the
|
40 |
+
same serial number as that of the case
|
41 |
+
'''
|
42 |
+
return (self.input_charging_case_serial == self.input_box_serial_number )
|
43 |
+
|
44 |
+
|
45 |
+
def check_model_number(self):
|
46 |
+
'''
|
47 |
+
Function to check if the airbuds are having the
|
48 |
+
same serial number as that of the case
|
49 |
+
'''
|
50 |
+
return (self.input_leftbud_model in self.master[self.input_model]['Model_number'] and self.input_rightbud_model in self.master[self.input_model]['Model_number'] )
|
51 |
+
|
52 |
+
def final_check(self):
|
53 |
+
|
54 |
+
if (self.Iterative_Serial_Check() and self.check_latest_firmware() and self.check_matching_serial() and self.check_model_number() ):
|
55 |
+
return 'Congratulations, Your Earpods/ Headphones are Genuine'
|
56 |
+
elif (self.check_latest_firmware() and self.check_matching_serial() and self.check_model_number() ):
|
57 |
+
return 'Looks like Earpods/ Headphones are mostly Genuine, but Case has been swapped'
|
58 |
+
else:
|
59 |
+
return 'Extremly sorry, Your Earpods/ Headphones are Probably Knock off'
|
60 |
+
|
61 |
+
def app_check(input_model,input_charging_case_serial,input_box_serial_number,input_leftbud_model,input_rightbud_model,input_leftbud_serial,input_rightbud_serial,input_firmware):
|
62 |
+
input_dict = ast.literal_eval(os.environ.get('master'))
|
63 |
+
if not (any([len(input_charging_case_serial) , (input_charging_case_serial) , len(input_leftbud_serial) , len(input_rightbud_serial)]) <= 10 or any([len(input_charging_case_serial) , (input_charging_case_serial) , len(input_leftbud_serial) , len(input_rightbud_serial)]) >= 15):
|
64 |
+
airpod = airpods(input_dict,input_model,input_charging_case_serial,input_box_serial_number,input_leftbud_model,input_rightbud_model,input_leftbud_serial,input_rightbud_serial,input_firmware)
|
65 |
+
return airpod.final_check()
|
66 |
+
else:
|
67 |
+
return 'the serial numbers are not correct, please check and re enter'
|
68 |
+
|
69 |
+
gr.Interface(fn=app_check,
|
70 |
+
inputs=[
|
71 |
+
gr.inputs.Dropdown(['AirPods_Pro2', 'AirPods_3', 'AirPods_Max', 'AirPods_Pro', 'AirPods_2', 'AirPods_1']),
|
72 |
+
gr.inputs.Textbox(
|
73 |
+
placeholder="Please enter the CharginCase serial number", label="CharginCase serial number", lines=1,),
|
74 |
+
gr.inputs.Textbox(
|
75 |
+
placeholder="Please enter the Box serial number", label="Box serial number", lines=1),
|
76 |
+
gr.inputs.Textbox(
|
77 |
+
placeholder="Please enter the left bud model number A2083", label="Left bud model number", lines=1),
|
78 |
+
gr.inputs.Textbox(
|
79 |
+
placeholder="Please enter the right bud number A2083", label="Right bud number", lines=1),
|
80 |
+
gr.inputs.Textbox(
|
81 |
+
placeholder="Please enter the left bud serial number", label="Left bud serial number", lines=1),
|
82 |
+
|
83 |
+
gr.inputs.Textbox(
|
84 |
+
placeholder="Please enter the right bud number", label="Right bud number", lines=1),
|
85 |
+
gr.inputs.Textbox(
|
86 |
+
placeholder="Please enter the Firmware", label="Firmware", lines=1)
|
87 |
+
],
|
88 |
+
outputs= [gr.outputs.Textbox(label="Output Box")],
|
89 |
+
examples=[]).launch(debug= True)
|
90 |
+
|
91 |
+
input_model = 'AirPods_Pro'
|
92 |
+
input_charging_case_serial = 'case_abf'
|
93 |
+
input_box_serial_number = 'case_abf'
|
94 |
+
input_leftbud_model = 'A2084'
|
95 |
+
input_rightbud_model = 'A2083'
|
96 |
+
input_leftbud_serial = 'bud_abd'
|
97 |
+
input_rightbud_serial = 'bud_abe'
|
98 |
+
input_firmware = '5B58'
|
99 |
+
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
pandas
|