Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Error "NoneType" #2

Open
mrivky67 opened this issue Jul 6, 2023 · 2 comments
Open

Error "NoneType" #2

mrivky67 opened this issue Jul 6, 2023 · 2 comments

Comments

@mrivky67
Copy link

mrivky67 commented Jul 6, 2023

Traceback (most recent call last):
File "/storage/emulated/0/create.py", line 676, in
menu()
File "/storage/emulated/0/create.py", line 218, in init
self.main_menu()
File "/storage/emulated/0/create.py", line 226, in main_menu
if x in ['1','01','001','a']: menu_create()
^^^^^^^^^^^^^
File "/storage/emulated/0/create.py", line 273, in init
if key/len(auth1) == len(reco)/2: create_fb(); self.hitung(l)
^^^^^^^^^^^
File "/storage/emulated/0/create.py", line 300, in init
self.scrap1()
File "/storage/emulated/0/create.py", line 457, in scrap1
if 'login/device-based/update-nonce' in str(rog['action']): #--> Jika Masuk Menu Save Device
~^^^^^^^^^^
TypeError: 'NoneType' object is not subscriptable

@noe999x
Copy link

noe999x commented Aug 6, 2023

Dalam kasus error tersebut, jika pos.find('form',{'method':'post'}) mengembalikan None, maka mencoba mengakses rog['action'] akan menyebabkan error 'NoneType' object is not subscriptable.

Untuk mengatasi masalah ini, Anda dapat menambahkan pengecekan tambahan untuk memastikan rog bukan None sebelum mencoba mengakses 'action' di dalamnya.

/Check sumber code pada line 401

Code sebelumnya:

            else:
                rog = pos.find('form',{'method':'post'})
                if 'login/device-based/update-nonce' in str(rog['action']): #--> Jika Masuk Menu Save Device
                    self.scrap2(rog)
                elif 'conf/notifmedium/send_code' in str(rog['action']): #--> Jika Langsung Masuk Menu Minta Kode Nope
                    self.scrap3(rog)
                elif 'checkpoint' in str(rog['action']): #--> Jika Checkpoint
                    self.printing('CP')
                else:
                    print('\rTerjadi Kesalahan                    ',end='');sys.stdout.flush()

setelah diubah:

            else:
                rog = pos.find('form',{'method':'post'})
                if rog is not None:
                   if 'login/device-based/update-nonce' in str(rog.get('action', '')):
                       self.scrap2(rog)
                   elif 'conf/notifmedium/send_code' in str(rog.get('action', '')):
                       self.scrap3(rog)
                   elif 'checkpoint' in str(rog.get('action', '')):
                       self.printing('CP')
                else:
                    print('\rTerjadi Kesalahan                    ',end='');sys.stdout.flush()

Dengan menggunakan metode rog.get('action', ''), Anda dapat menghindari error saat rog adalah None, dan juga menghindari kesalahan jika 'action' tidak ada dalam rog. Jika 'action' tidak ditemukan, maka metode get akan mengembalikan string kosong, sehingga kondisi percabangan akan bekerja dengan benar.

@Danmingking
Copy link

tre

uda diedit sesuai metode rog.get('action', '') , msh tetap error puh..
no attribute 'group'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants
@noe999x @mrivky67 @Danmingking and others