-1

It's my first time trying tkinter and I can't get over this error. Can someone tell me what's wrong with it and suggest a fix?

I get TypeError: repip() takes exactly 1 argument (0 given) error.

import Tkinter as tk
from Tkinter import *
import ttk
import tkFileDialog as filedialog
import os
import requests
from multiprocessing import Pool
from multiprocessing.dummy import Pool as ThreadPool
from re import findall as reg
import shutil

main_window = tk.Tk()
main_window.title('sample 1')
main_window.resizable(False, False)
main_window.geometry("390x400")

def open_file(file):
   file = filedialog.askopenfile(mode='r', filetypes=[('text files', '*.txt')])
   file = open(file, 'r').read().splitlines()
   Thread = 50
   pool = ThreadPool(int(Thread))
   pool.map(repip, file)
   pool.close()
   pool.join()
   if file:
      filepath = os.path.abspath(file.name)
      entry1.insert(END, filepath)


def repip(file):
    try:
        grab = requests.get('https://tools.webservertalk.com/?tool=reverseip&host='+file).content
        if 'Domain / IP:' in grab:
            regx = reg('<td class="text-left">(.*?)<', grab)
            for ckk in regx:
                mek = ckk.replace("Domain","")
                listbox.insert("{}[Grabbed] {}".format(Fore.YELLOW, str(mek)))
                open('grabbed.txt', 'a').write('http://'+mek+'\n')
            else:
                print "{}[Operation timed out] {}".format(Fore.RED, str(url))
    except:
        pass


label = Label(main_window, text="Select domain list")
label.grid(row=0, sticky=W, pady=3, padx=3)

entry1 = tk.Entry(main_window, width=50)
entry1.grid(row=1, sticky=W, pady=3, padx=3)

ttk.Button(main_window, text="Browse", command=open_file).grid(row=1, column=1, sticky=W, pady=2)
ttk.Button(main_window, text="Start", command=repip).grid(row=2, column=1, sticky=W, pady=2)

listbox = Listbox(main_window, width=50, height=20)
listbox.place(x=2, y=60)

scrollbar = Scrollbar(main_window, orient="vertical", command=listbox.yview)
scrollbar.place(x=290, y=60, height=323)
listbox.config(yscrollcommand=scrollbar.set)

tk.mainloop()
Thingamabobs
  • 7,274
  • 5
  • 21
  • 54
  • 2
    `def repip(file):` the argument *file* is needed. To pass a predefined argument via `tk.Button`, *lambda* is needed. [See here for exampel](https://stackoverflow.com/a/6921225/13629335) – Thingamabobs Nov 09 '21 at 14:26
  • 1
    Even if its not related to your question, but you should consider to work with python 3. The support for python 2.x isn't guaranteed anymore. – Thingamabobs Nov 09 '21 at 14:54

1 Answers1

-1

The second argument for pool.map is an iterable, like a list. Wrap around the file in square brackets and it should work:

pool.map(repip, [file])
qucchia
  • 95
  • 7
  • I added lambda but the process doesn't start on click and it doesn't give an error. https://pastebin.com/raw/LATwyG0B – Mustafa Ajmail Nov 09 '21 at 16:01
  • If you use `pool.map(repip, [file])`, you don't need to use lambda. Perhaps there is a problem somewhere else in the code. – qucchia Nov 09 '21 at 17:09