Skip to main content

A etool package for security monitoring

Project description

中文 | English

Installation

Install etool using pip:

pip install -U etool

Features and Usage Examples

Network

Test Network Speed

from etool import ManagerSpeed
ManagerSpeed.network() # Network test
ManagerSpeed.disk() # Disk test
ManagerSpeed.memory() # Memory test
ManagerSpeed.gpu_memory() # GPU test

Screen and File Sharing

Share Screen

from etool import ManagerShare
ManagerShare.screen_share() # Share screen

Share File

from etool import ManagerShare
ManagerShare.share_file() # Share file

Office

PDF Processing

from etool import ManagerPdf

# Convert doc, xlsx, etc. to pdf (convert one file)
ManagerPdf.pdfconverter(os.path.join(os.path.dirname(__file__),'pdf','ex1.docx'),os.path.join(os.path.dirname(__file__),'pdf_out'))
# Convert doc, xlsx, etc. to pdf (convert all files in a directory)
ManagerPdf.pdfconverter(os.path.join(os.path.dirname(__file__),'pdf'),os.path.join(os.path.dirname(__file__),'pdf_out'))

# Add watermark to pdf files (one file)
ManagerPdf.create_watermarks(os.path.join(os.path.dirname(__file__),'pdf_out','ex1.pdf'),os.path.join(os.path.dirname(__file__),'pdf_out','watermarks.pdf'),os.path.join(os.path.dirname(__file__),'pdf_out_watermark'))
# Add watermark to pdf files (all files in a directory)
ManagerPdf.create_watermarks(os.path.join(os.path.dirname(__file__),'pdf_out'),os.path.join(os.path.dirname(__file__),'pdf_out','watermarks.pdf'),os.path.join(os.path.dirname(__file__),'pdf_out_watermark'))

# Encrypt pdf files
ManagerPdf.encrypt_pdf(os.path.join(os.path.dirname(__file__),'pdf_out','ex1.pdf'),r"1234567890")
# Decrypt pdf files
ManagerPdf.decrypt_pdf(os.path.join(os.path.dirname(__file__),'pdf_out','ex1_encrypted.pdf'),r"1234567890")

# Split pdf files (by pages) every 3 pages
ManagerPdf.split_by_pages(os.path.join(os.path.dirname(__file__),'pdf_out','merged.pdf'),3)
# Split pdf files (by number) into 2 parts
ManagerPdf.split_by_num(os.path.join(os.path.dirname(__file__),'pdf_out','merged.pdf'),2)

# Insert pdf ex2 into a specific page of pdf ex1
ManagerPdf.insert_pdf(os.path.join(os.path.dirname(__file__),'pdf_out','ex1.pdf'),os.path.join(os.path.dirname(__file__),'pdf_out','ex2.pdf'),0,os.path.join(os.path.dirname(__file__),'pdf_out','pdf_insert.pdf'))

docx Processing

from etool import ManagerDocx
word_path = 'ex1.docx' # docx file path
result_path = 'result' # save path
ManagerDocx.replace_words(word_path, '1', '2') # Replace text in document
ManagerDocx.change_forward(word_path, 'result.docx') # Change document format
ManagerDocx.get_pictures(word_path, result_path) # Extract images from docx to result folder

Email Sending

from etool import ManagerEmail
ManagerEmail.send_email(
    sender='1234567890@qq.com',
    password='1234567890',
    recipient='1234567890@qq.com',
    subject='Test Email',
    message='Test email content',
    file_path='test.txt',
    image_path='test.webp'
) # Send email

Image Processing

from etool import ManagerImage
pics = ['pic1.webp', 'pic2.webp'] # List of image paths
ManagerImage.merge_LR(pics) # Merge left and right
ManagerImage.merge_UD(pics) # Merge up and down
ManagerImage.fill_image('pic1_UD.webp') # Fill image
ManagerImage.cut_image('pic1_UD_fill.webp') # Cut image
ManagerImage.rename_images('tests', remove=True) # Rename images

Excel Processing

from etool import ManagerExcel
excel_path = 'ex1.xlsx' # Excel file path
save_path = 'result.xlsx' # Save path
ManagerExcel.excel_format(excel_path, save_path) # Copy style from ex1.xlsx to result.xlsx

QR Code Generation

from etool import ManagerQrcode
qr_path = 'qr.png' # Save path
ManagerQrcode.generate_english_qrcode(words='https://www.baidu.com', qr_path) # Generate QR code without Chinese
ManagerQrcode.generate_qrcode(words='百度', qr_path) # Generate QR code with Chinese
ManagerQrcode.decode_qrcode(qr_path) # Decode QR code

ipynb Conversion

from etool import ManagerIpynb
ipynb_dir = 'ipynb_dir' # ipynb directory path
md_dir = 'md' # md directory path

ManagerIpynb.merge_notebooks(ipynb_dir) # Merge ipynb files
ManagerIpynb.convert_notebook_to_markdown(ipynb_dir+'.ipynb', md_dir) # Convert ipynb files to md files

Markdown Processing

from etool import ManagerMd

# Convert Markdown to Word document
ManagerMd.convert_md_to_docx("document.md", "document.docx")

# Convert Markdown to HTML webpage
ManagerMd.convert_md_to_html("document.md", "document.html")

# Extract tables from Markdown to Excel
ManagerMd.extract_tables_to_excel("document.md", "tables.xlsx")

Others

Task Scheduling

from etool import ManagerScheduler

def job():
    print("job")
    raise Exception("error")

def func_success():
    print("success")

def func_failure():
    print("failure")

ManagerScheduler.pocwatch(job, 2, func_success, func_failure)
"""
- `job`: Task function
- `schedule_time`: Execution time
- `func_success`: Callback function on task success
- `func_failure`: Callback function on task failure

`schedule_time` format:

If it's a number, the default unit is seconds, executed every `schedule_time` seconds, e.g., `120` means every 2 minutes.

If it's a string, the default is a time point, follow the `HH:MM` format, e.g., `08:00`, executed once daily at this time.

If it's a list, the default is multiple time points, e.g., `["08:00", "12:00", "16:00"]`, executed daily at these times.

If a dictionary is passed, parse the dictionary keys:

If the key is a number, the default is a date, the corresponding value follows the above number, string, list judgment.

If the key is a string, the default is a weekday (e.g., Monday, supported formats include: `1`, `monday`, `Monday`, `MONDAY`, `mon`, `mon.`, `m`), the corresponding value follows the above number, string, list judgment.

For example, the 1st at 8:00, the 2nd at 8:00, 12:00, 16:00, the 3rd every hour, every Monday at 8:00.

schedule_time = {
1: "08:00",
2: ["08:00", "12:00", "16:00"],
3: 216000,
"1": "08:00",
}

"""
# If you're unsure about the schedule time, use the parse_schedule_time function to confirm
ManagerScheduler.parse_schedule_time(120)
ManagerScheduler.parse_schedule_time("08:00")
ManagerScheduler.parse_schedule_time(["08:00", "12:00", "16:00"])
ManagerScheduler.parse_schedule_time({1: "08:00", 2: ["08:00", "12:00", "16:00"], 3: 216000, "1": "08:00"})

Password Generation and Base Conversion

from etool import ManagerPassword
print(ManagerPassword.generate_pwd_list(ManagerPassword.results['all_letters'] + ManagerPassword.results['digits'], 2))
# Generate all possible 2-digit passwords (for password cracking)
print(ManagerPassword.random_pwd(8))
# Randomly generate an 8-digit password (random encryption)

print(ManagerPassword.convert_base("A1F", 16, 2))
# Convert 16-digit to 2-digit
print(ManagerPassword.convert_base("-1101", 2, 16))
# Convert 2-digit to 16-digit
print(ManagerPassword.convert_base("Z", 36, 10))
# Convert 36-digit to 10-digit

Install Dependencies

from etool import ManagerInstall
ManagerInstall.install(requirements_file="requirements.txt", failed_file="failed_requirements.txt", retry=2)
# Automatically install dependencies, retry 2 times if installation fails, skip installation if successful. The above are default parameters.
# You can also use the default parameters without specifying parameters.  
ManagerInstall.install()

Manage Windows Right-Click Menu

from etool import ManagerMenu
ManagerMenu.switch_to_classic_menu() # Switch to Windows 11 classic right-click menu
ManagerMenu.switch_to_new_menu() # Switch to Windows 11 new right-click menu
ManagerMenu.add_cursor_context_menu() # Add Cursor to Windows right-click menu
ManagerMenu.remove_cursor_context_menu() # Remove Cursor from Windows right-click menu

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

etool-1.4.3.tar.gz (33.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

etool-1.4.3-py3-none-any.whl (33.8 kB view details)

Uploaded Python 3

File details

Details for the file etool-1.4.3.tar.gz.

File metadata

  • Download URL: etool-1.4.3.tar.gz
  • Upload date:
  • Size: 33.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for etool-1.4.3.tar.gz
Algorithm Hash digest
SHA256 984c8da63e15fb56e5863e5b6139d1731d48661ee75ad52f50dfd60f99177a20
MD5 af6ef0eec209ba1bf814b972a0e7c95c
BLAKE2b-256 79232f32aaa232b049dd624f9275bd4d04e87b0b1189013852e4d969f666adc3

See more details on using hashes here.

File details

Details for the file etool-1.4.3-py3-none-any.whl.

File metadata

  • Download URL: etool-1.4.3-py3-none-any.whl
  • Upload date:
  • Size: 33.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for etool-1.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b5e923d7069accc14ffe4232ecf8ca5f1f2ccc1c0cca635c3e1aa7f1964a1849
MD5 b97e41e111968cc241a6efd7b8084273
BLAKE2b-256 3f089c3825fb0ced919b6905fc4fc0aeeb28cfb0f11956abaf57b8c071827e6a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page