Browse Source

Merge branch 'release/v1.2.4'

liuyuqi-dellpc 8 months ago
parent
commit
b016e44876

+ 21 - 17
main.py

@@ -15,20 +15,24 @@ from searchdomain.options import parse_args
 import sys
 
 if __name__== "__main__":
-    args = parse_args()
-    if args.get("command","")=="generate":
-        if args.get("lang","en")=="en":
-            generateDomain = GenerateEnDomain(params=args) 
-        elif args.get("lang", "en")=="zh":
-            generateDomain = GenerateDomain(params=args)
-        generateDomain.run()
-    elif args.get("command","")=="search":
-        serachdomain = SearchDomain(params=args, debug=True, export_all=True) 
-        serachdomain.run()
-    elif args.get("command","")=="version":
-        # print(__verison__)
-        pass
-    else:
-        print("please input command: generate, search")
-        print(args.get('command',""))
-        sys.exit(1)
+    try:
+        args = parse_args()
+        if args.get("command","")=="generate":
+            if args.get("lang","en")=="en":
+                generateDomain = GenerateEnDomain(params=args) 
+            elif args.get("lang", "en")=="zh":
+                generateDomain = GenerateDomain(params=args)
+            generateDomain.run()
+        elif args.get("command","")=="search":
+            serachdomain = SearchDomain(params=args, debug=True, export_all=True) 
+            serachdomain.run()
+        elif args.get("command","")=="version":
+            # print(__verison__)
+            pass
+        else:
+            print("please input command: generate, search")
+            print(args.get('command',""))
+            sys.exit(1)
+    except Exception as e:
+        with open('error.log', 'w') as f:
+            f.write(str(e))

+ 28 - 29
poetry.lock

@@ -38,13 +38,13 @@ altgraph = ">=0.17"
 
 [[package]]
 name = "packaging"
-version = "24.0"
+version = "24.1"
 description = "Core utilities for Python packages"
 optional = false
-python-versions = ">=3.7"
+python-versions = ">=3.8"
 files = [
-    {file = "packaging-24.0-py3-none-any.whl", hash = "sha256:2ddfb553fdf02fb784c234c7ba6ccc288296ceabec964ad2eae3777778130bc5"},
-    {file = "packaging-24.0.tar.gz", hash = "sha256:eb82c5e3e56209074766e6885bb04b8c38a0c015d0a30036ebe7ece34c9989e9"},
+    {file = "packaging-24.1-py3-none-any.whl", hash = "sha256:5b8f2217dbdbd2f7f384c41c628544e6d52f2d0f53c6d0c3ea61aa5d1d7ff124"},
+    {file = "packaging-24.1.tar.gz", hash = "sha256:026ed72c8ed3fcce5bf8950572258698927fd1dbda10a5e981cdf0ac37f4f002"},
 ]
 
 [[package]]
@@ -60,23 +60,23 @@ files = [
 
 [[package]]
 name = "pyinstaller"
-version = "6.6.0"
+version = "6.8.0"
 description = "PyInstaller bundles a Python application and all its dependencies into a single package."
 optional = false
 python-versions = "<3.13,>=3.8"
 files = [
-    {file = "pyinstaller-6.6.0-py3-none-macosx_10_13_universal2.whl", hash = "sha256:d2705efe79f8749526f65c4bce70ae88eea8b6adfb051f123122e86542fe3802"},
-    {file = "pyinstaller-6.6.0-py3-none-manylinux2014_aarch64.whl", hash = "sha256:2aa771693ee3e0a899be3e9d946a24eab9896a98d0d4035f05a22f1193004cfb"},
-    {file = "pyinstaller-6.6.0-py3-none-manylinux2014_i686.whl", hash = "sha256:1fc15e8cebf76361568359a40926aa5746fc0a84ca365fb2ac6caeea014a2cd3"},
-    {file = "pyinstaller-6.6.0-py3-none-manylinux2014_ppc64le.whl", hash = "sha256:7c4a55a5d872c118bc7a5e641c2df46ad18585c002d96adad129b4ee8c104463"},
-    {file = "pyinstaller-6.6.0-py3-none-manylinux2014_s390x.whl", hash = "sha256:97197593344f11f3dd2bdadbab14c61fbc4cdf9cc692a89b047cb671764c1824"},
-    {file = "pyinstaller-6.6.0-py3-none-manylinux2014_x86_64.whl", hash = "sha256:00d81ddeee97710245a7ed03b0f9d5a4daf6c3a07adf978487b10991e1e20470"},
-    {file = "pyinstaller-6.6.0-py3-none-musllinux_1_1_aarch64.whl", hash = "sha256:b7cab21db6fcfbdab47ee960239d1b44cd95383a4463177bd592613941d67959"},
-    {file = "pyinstaller-6.6.0-py3-none-musllinux_1_1_x86_64.whl", hash = "sha256:00996d2090734d9ae4a1e53ed40351b07d593c37118d3e0d435bbcfa8db9edee"},
-    {file = "pyinstaller-6.6.0-py3-none-win32.whl", hash = "sha256:cfe3ed214601de0723cb660994b44934efacb77a1cf0e4cc5133da996bcf36ce"},
-    {file = "pyinstaller-6.6.0-py3-none-win_amd64.whl", hash = "sha256:e2f55fbbdf8a99ea84b39bc5669a68624473c303486d7eb2cd9063b339f0aa28"},
-    {file = "pyinstaller-6.6.0-py3-none-win_arm64.whl", hash = "sha256:abbd591967593dab264bcc3bcb2466c0a1582f19a112e37e916c4212069c7933"},
-    {file = "pyinstaller-6.6.0.tar.gz", hash = "sha256:be6bc2c3073d3e84fb7148d3af33ce9b6a7f01cfb154e06314cd1d4c05798a32"},
+    {file = "pyinstaller-6.8.0-py3-none-macosx_10_13_universal2.whl", hash = "sha256:5ff6bc2784c1026f8e2f04aa3760cbed41408e108a9d4cf1dd52ee8351a3f6e1"},
+    {file = "pyinstaller-6.8.0-py3-none-manylinux2014_aarch64.whl", hash = "sha256:39ac424d2ee2457d2ab11a5091436e75a0cccae207d460d180aa1fcbbafdd528"},
+    {file = "pyinstaller-6.8.0-py3-none-manylinux2014_i686.whl", hash = "sha256:355832a3acc7de90a255ecacd4b9f9e166a547a79c8905d49f14e3a75c1acdb9"},
+    {file = "pyinstaller-6.8.0-py3-none-manylinux2014_ppc64le.whl", hash = "sha256:6303c7a009f47e6a96ef65aed49f41e36ece8d079b9193ca92fe807403e5fe80"},
+    {file = "pyinstaller-6.8.0-py3-none-manylinux2014_s390x.whl", hash = "sha256:2b71509468c811968c0b5decb5bbe85b6292ea52d7b1f26313d2aabb673fa9a5"},
+    {file = "pyinstaller-6.8.0-py3-none-manylinux2014_x86_64.whl", hash = "sha256:ff31c5b99e05a4384bbe2071df67ec8b2b347640a375eae9b40218be2f1754c6"},
+    {file = "pyinstaller-6.8.0-py3-none-musllinux_1_1_aarch64.whl", hash = "sha256:000c36b13fe4cd8d0d8c2bc855b1ddcf39867b5adf389e6b5ca45b25fa3e619d"},
+    {file = "pyinstaller-6.8.0-py3-none-musllinux_1_1_x86_64.whl", hash = "sha256:fe0af018d7d5077180e3144ada89a4da5df8d07716eb7e9482834a56dc57a4e8"},
+    {file = "pyinstaller-6.8.0-py3-none-win32.whl", hash = "sha256:d257f6645c7334cbd66f38a4fac62c3ad614cc46302b2b5d9f8cc48c563bce0e"},
+    {file = "pyinstaller-6.8.0-py3-none-win_amd64.whl", hash = "sha256:81cccfa9b16699b457f4788c5cc119b50f3cd4d0db924955f15c33f2ad27a50d"},
+    {file = "pyinstaller-6.8.0-py3-none-win_arm64.whl", hash = "sha256:1c3060a263758cf7f0144ab4c016097b20451b2469d468763414665db1bb743d"},
+    {file = "pyinstaller-6.8.0.tar.gz", hash = "sha256:3f4b6520f4423fe19bcc2fd63ab7238851ae2bdcbc98f25bc5d2f97cc62012e9"},
 ]
 
 [package.dependencies]
@@ -84,7 +84,7 @@ altgraph = "*"
 macholib = {version = ">=1.8", markers = "sys_platform == \"darwin\""}
 packaging = ">=22.0"
 pefile = {version = ">=2022.5.30", markers = "sys_platform == \"win32\""}
-pyinstaller-hooks-contrib = ">=2024.3"
+pyinstaller-hooks-contrib = ">=2024.6"
 pywin32-ctypes = {version = ">=0.2.1", markers = "sys_platform == \"win32\""}
 setuptools = ">=42.0.0"
 
@@ -94,13 +94,13 @@ hook-testing = ["execnet (>=1.5.0)", "psutil", "pytest (>=2.7.3)"]
 
 [[package]]
 name = "pyinstaller-hooks-contrib"
-version = "2024.5"
+version = "2024.7"
 description = "Community maintained hooks for PyInstaller"
 optional = false
 python-versions = ">=3.7"
 files = [
-    {file = "pyinstaller_hooks_contrib-2024.5-py2.py3-none-any.whl", hash = "sha256:0852249b7fb1e9394f8f22af2c22fa5294c2c0366157969f98c96df62410c4c6"},
-    {file = "pyinstaller_hooks_contrib-2024.5.tar.gz", hash = "sha256:aa5dee25ea7ca317ad46fa16b5afc8dba3b0e43f2847e498930138885efd3cab"},
+    {file = "pyinstaller_hooks_contrib-2024.7-py2.py3-none-any.whl", hash = "sha256:8bf0775771fbaf96bcd2f4dfd6f7ae6c1dd1b1efe254c7e50477b3c08e7841d8"},
+    {file = "pyinstaller_hooks_contrib-2024.7.tar.gz", hash = "sha256:fd5f37dcf99bece184e40642af88be16a9b89613ecb958a8bd1136634fc9fac5"},
 ]
 
 [package.dependencies]
@@ -136,21 +136,20 @@ files = [
 
 [[package]]
 name = "setuptools"
-version = "69.5.1"
+version = "70.1.0"
 description = "Easily download, build, install, upgrade, and uninstall Python packages"
 optional = false
 python-versions = ">=3.8"
 files = [
-    {file = "setuptools-69.5.1-py3-none-any.whl", hash = "sha256:c636ac361bc47580504644275c9ad802c50415c7522212252c033bd15f301f32"},
-    {file = "setuptools-69.5.1.tar.gz", hash = "sha256:6c1fccdac05a97e598fb0ae3bbed5904ccb317337a51139dcd51453611bbb987"},
+    {file = "setuptools-70.1.0-py3-none-any.whl", hash = "sha256:d9b8b771455a97c8a9f3ab3448ebe0b29b5e105f1228bba41028be116985a267"},
+    {file = "setuptools-70.1.0.tar.gz", hash = "sha256:01a1e793faa5bd89abc851fa15d0a0db26f160890c7102cd8dce643e886b47f5"},
 ]
 
 [package.extras]
-docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "pygments-github-lexers (==0.0.5)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-favicon", "sphinx-inline-tabs", "sphinx-lint", "sphinx-notfound-page (>=1,<2)", "sphinx-reredirects", "sphinxcontrib-towncrier"]
-testing = ["build[virtualenv]", "filelock (>=3.4.0)", "importlib-metadata", "ini2toml[lite] (>=0.9)", "jaraco.develop (>=7.21)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "mypy (==1.9)", "packaging (>=23.2)", "pip (>=19.1)", "pytest (>=6,!=8.1.1)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-home (>=0.5)", "pytest-mypy", "pytest-perf", "pytest-ruff (>=0.2.1)", "pytest-timeout", "pytest-xdist (>=3)", "tomli", "tomli-w (>=1.0.0)", "virtualenv (>=13.0.0)", "wheel"]
-testing-integration = ["build[virtualenv] (>=1.0.3)", "filelock (>=3.4.0)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "packaging (>=23.2)", "pytest", "pytest-enabler", "pytest-xdist", "tomli", "virtualenv (>=13.0.0)", "wheel"]
+docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "pygments-github-lexers (==0.0.5)", "pyproject-hooks (!=1.1)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-favicon", "sphinx-inline-tabs", "sphinx-lint", "sphinx-notfound-page (>=1,<2)", "sphinx-reredirects", "sphinxcontrib-towncrier"]
+testing = ["build[virtualenv] (>=1.0.3)", "filelock (>=3.4.0)", "importlib-metadata", "ini2toml[lite] (>=0.14)", "jaraco.develop (>=7.21)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "jaraco.test", "mypy (==1.10.0)", "packaging (>=23.2)", "pip (>=19.1)", "pyproject-hooks (!=1.1)", "pytest (>=6,!=8.1.1)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-home (>=0.5)", "pytest-mypy", "pytest-perf", "pytest-ruff (>=0.3.2)", "pytest-subprocess", "pytest-timeout", "pytest-xdist (>=3)", "tomli", "tomli-w (>=1.0.0)", "virtualenv (>=13.0.0)", "wheel"]
 
 [metadata]
 lock-version = "2.0"
-python-versions = ">=3.12,<3.13"
-content-hash = "c7e62ff041cfe41f0aa188f376169281d0468510a81ba4bd22e1d10463bd0c71"
+python-versions = ">=3.11.5,<3.13"
+content-hash = "56f988b1e107186c68aa424bf058e6d7853a98ad6d062129b56ee53b335487fd"

+ 1 - 1
pyproject.toml

@@ -6,7 +6,7 @@ authors = ["fish <zz1036@qq.com>"]
 readme = "README.md"
 
 [tool.poetry.dependencies]
-python = ">=3.12,<3.13"
+python = ">=3.11.5,<3.13"
 python-whois = "0.8.0"
 
 

+ 3 - 3
searchdomain/generate_domain.py

@@ -10,7 +10,7 @@
 
 '''
 
-import csv
+import csv,os
 
 class GenerateDomain(object):
     
@@ -27,7 +27,7 @@ class GenerateDomain(object):
 
     def run(self):
         """ 批量生成域名, 保存到 domain.txt """
-        with open(("data/a.csv"), "r", encoding="utf-8") as f:
+        with open(os.path.join(self.params["app_path"], r"data/a.csv"), "r", encoding="utf-8") as f:
             csv_data = csv.reader(f)
             for row in csv_data:
                 for pinyin in row:
@@ -45,6 +45,6 @@ class GenerateDomain(object):
                 for j in self.yuming:
                     self.composeDomain.append(i+"."+j)
 
-            with open("domain.txt","w",encoding="utf-8") as file:
+            with open(os.path.join(self.params["app_path"], "domain.txt"),"w",encoding="utf-8") as file:
                 for i in self.composeDomain:
                     file.write(i+"\n")

+ 3 - 3
searchdomain/generate_en_domain.py

@@ -10,7 +10,7 @@
 
 '''
 
-import csv
+import csv,os
 
 class GenerateEnDomain(object):
     
@@ -27,7 +27,7 @@ class GenerateEnDomain(object):
         self.composePinYin=[]
 
     def run(self):
-        with open((r"data/b.csv"), "r", encoding="utf-8") as f:
+        with open(os.path.join(self.params["app_path"], r"data/b.csv"), "r", encoding="utf-8") as f:
             csv_data = f.readlines()
             for row in csv_data:
                 self.initList.append(row.strip())
@@ -43,6 +43,6 @@ class GenerateEnDomain(object):
                 for j in self.yuming:
                     self.composeDomain.append(i+"."+j)
 
-            with open("domain.txt","w",encoding="utf-8") as file:
+            with open(os.path.join(self.params["app_path"], "domain.txt"),"w",encoding="utf-8") as file:
                 for i in self.composeDomain:
                     file.write(i+"\n")

+ 4 - 1
searchdomain/options.py

@@ -10,7 +10,7 @@
 import sys,os,re
 import argparse
 from collections import OrderedDict
-
+from searchdomain.utils.frozen_dir import get_app_path
 def parse_args():
     parser = argparse.ArgumentParser(description='search domain')
     parser.add_argument('command',  help='command: generate, search', choices=['generate','search', 'help','version'] , default='help')
@@ -32,6 +32,9 @@ def parse_args():
     )
     system_conf = user_conf = custom_conf = OrderedDict()
     system_conf.update(command_line_conf)
+
+    app_path = get_app_path()
+    system_conf["app_path"] = app_path
     return system_conf
 
 def _read_custom_conf(config_path: str) -> OrderedDict:

+ 3 - 3
searchdomain/searchdomain.py

@@ -1,6 +1,6 @@
 import whois
 from concurrent.futures import ThreadPoolExecutor
-import logging
+import logging,os
 import argparse
 from . import db
 
@@ -48,11 +48,11 @@ class SearchDomain(object):
     def saveRes(self, domain: str, res: bool):
         """ save result to file """
         # db.Mysql().save()
-        db.File().save(self.output, domain + "    " + str(res))
+        db.File().save(os.path.join(self.params["app_path"], self.output), domain + "    " + str(res))
 
     def run(self):
         '''begin search domain'''
-        with open(self.input, "r", encoding="utf8", errors="ignore") as file:
+        with open(os.path.join(self.params["app_path"], self.input), "r", encoding="utf8", errors="ignore") as file:
             pool = ThreadPoolExecutor(max_workers=5)
             index = 0
             for line in file.readlines():

+ 18 - 0
searchdomain/utils/frozen_dir.py

@@ -0,0 +1,18 @@
+#!/usr/bin/env python
+# -*- encoding: utf-8 -*-
+"""
+@Contact :   liuyuqi.gov@msn.cn
+@Time    :   2024/04/12
+@License :   Copyright © 2017-2022 liuyuqi. All Rights Reserved.
+@Desc    :   
+"""
+import sys  
+import os  
+   
+def get_app_path() -> str:  
+    """Returns the base application path."""  
+    if hasattr(sys, 'frozen'):  
+        # Handles PyInstaller  
+        return os.path.dirname(sys.executable)  #使用 pyinstaller 打包后的 exe 目录
+    # return os.path.dirname(os.path.dirname(os.path.dirname(__file__))) # 没打包前的py目录
+    return sys.path[0]