I have a python package that has a .py file called cli.py. In the pacakge I keep getting a NameError: name 'op' is not defined because a variable was not defined. I updated the cli.py file but I can't seem to be able to see that in my python package.
The code in the cli.py file in my package is:
def get_google_header(url, file_path, file_name, h_area):
s = Service(ChromeDriverManager().install())
driver = webdriver.Chrome(service=s, options=op)
agent = driver.execute_script("return navigator.userAgent")
print(agent)
driver.maximize_window()
for files in os.listdir(file_path):
if files.endswith(file_name):
csv_name = file_path + files
print(csv_name)
But in my local file I have the code as:
def get_google_header(url, file_path, file_name, h_area):
op = webdriver.ChromeOptions()
# add user Agent
# op.add_argument
# ("user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64)"
# +"AppleWebKit/537.36 (KHTML, like Gecko)"
# +"Chrome/87.0.4280.141 Safari/537.36")
# set chromedriver.exe path
# driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe",
# options=op)
op.add_experimental_option("excludeSwitches", ["enable-automation"])
op.add_experimental_option('useAutomationExtension', False)
op.add_argument("--disable-gpu")
op.add_argument('--disable-dev-shm-usage')
op.add_argument('--no-sandbox')
s = Service(ChromeDriverManager().install())
driver = webdriver.Chrome(service=s, chrome_options=op)
agent = driver.execute_script("return navigator.userAgent")
print(agent)
driver.maximize_window()
for files in os.listdir(file_path):
if files.endswith(file_name):
csv_name = file_path + files
print(csv_name)
I have all the other package imported correctly. It's just that this latest code doesn't seem to be updated even if I run python3 -m build > python3 -m twine upload --verbose --repository testpypi dist/*
would greatly appreciate your help!