This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #๋ฐ์ฝ๋ ์ดํฐ | |
| # ํจ์๋ฅผ ์ธ์๋ก ๋ฐ์ ๊ธฐ๋ฅ์ ์ถ๊ฐํ ํ ๋ฐํํ๋ ํจ์ | |
| # ์ฆ, ๋ ํผํจ์ ์ญํ | |
| #---------------- | |
| # ์ฌ์ด ์ฝ๋ | |
| def announce(func): | |
| def wrapper(*args, **kargs): | |
| print(f"'{func.__name__}' ํจ์๊ฐ ์์๋ฉ๋๋ค.") | |
| result = func(*args, **kargs) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ############################# [A ํ๋ก๊ทธ๋จ = ๋ฉ์์ง ์ก์ ] | |
| import socket | |
| import argparse | |
| from cryptography.fernet import Fernet | |
| # ๋น๋ฐํค ์์ฑ | |
| KEY = Fernet.generate_key() | |
| # ํค๋ฅผ ํตํด ์๋ณตํธํ๋ฅผ ์ํํ๋ ๊ฐ์ฒด ์ด๊ธฐํ = ๋ฉ์์ง ์๋ณตํธํ์ ์ฌ์ฉ | |
| cipher_suite = Fernet(KEY) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ๋ ๊ฐ์ ๋์ ๋๋ฆฌ ์ ์ | |
| dict_a = {'์ด๋ฆ': 'ํ๊ธธ๋', '๋์ด': 30} | |
| dict_b = {'์ง์ ': '๊ฐ๋ฐ์', '์ง์ญ': '์์ธ'} | |
| # ๋์ ๋๋ฆฌ ํฉ์น๊ธฐ (dict_a์ dict_b ๋ด์ฉ ์ถ๊ฐ) | |
| dict_a.update(dict_b) | |
| # ๊ฒฐ๊ณผ ์ถ๋ ฅ | |
| print(dict_a) | |
| # {'์ด๋ฆ': 'ํ๊ธธ๋', '๋์ด': 30, '์ง์ ': '๊ฐ๋ฐ์', '์ง์ญ': '์์ธ'} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import threading | |
| import time | |
| # 1. SpinLock ๊ตฌํ | |
| class SpinLock: | |
| def __init__(self): | |
| self.lock = threading.Lock() # threading.Lock ๊ฐ์ฒด๋ฅผ ์์ฑํ์ฌ self.lock์ ํ ๋น. ๋ฝ์ ๊ด๋ฆฌํ๋ ๊ฐ์ฒด | |
| self.is_locked = False | |
| def acquire(self): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # [์ ํํ 1์ด ๋ง์ถฐ ๋ก์ง ์คํํ๊ธฐ] | |
| start_time = time.time() | |
| ~~ ๋ก์ง | |
| elapsed_time = time.time() - start_time | |
| timewait = max(0, 1 - elapsed_time) | |
| time.sleep(timewait) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from selenium import webdriver | |
| from selenium.webdriver.chrome.options import Options | |
| from bs4 import BeautifulSoup | |
| import time | |
| import re | |
| from selenium_stealth import stealth | |
| import os | |
| import pandas as pd | |
| import sys |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import subprocess | |
| import smtplib | |
| from email.mime.text import MIMEText | |
| from datetime import datetime | |
| import os | |
| # ๋ก๊ทธ ํ์ผ ์ค์ | |
| LOG_FILE = "/var/log/recent_patch.log" | |
| # ์ด๋ฉ์ผ ์๋ฆผ ์ค์ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import fnmatch | |
| # 2. find_files ํจ์ ์ ์ | |
| def find_files(directory, pattern): | |
| if not os.path.isdir(directory): | |
| print(f"Error: {directory} is not a valid") | |
| return | |
| # os.walk(): dir ์ํ ํจ์ |