-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtesting.py
122 lines (99 loc) · 4.3 KB
/
testing.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
"""
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
# Set up Chrome options for headless mode
chrome_options = Options()
chrome_options.add_argument("--headless") # Run Chrome in headless mode
chrome_options.add_argument("--no-sandbox") # Required for running as root in containers
chrome_options.add_argument("--disable-dev-shm-usage") # Overcome limited resource problems
chrome_options.add_argument("--disable-gpu") # Disable GPU acceleration
chrome_options.add_argument("--remote-debugging-port=9222") # Required for headless mode debugging
# Initialize ChromeDriver with webdriver-manager
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options)
# Test: Open a webpage
driver.get("https://www.google.com")
print(driver.title)
#############
import os
import hashlib
import json
import time
from elasticsearch import Elasticsearch
from elasticsearch_dsl import Index
# Ignore warnings
import warnings
from elasticsearch import ElasticsearchWarning
elasticsearch_host = "https://localhost:9200"
#elasticsearch_host = os.environ.get('ELASTICSEARCH_HOST')
#elasticsearch_port = int(os.environ.get('ELASTICSEARCH_PORT'))
if elasticsearch_host is None:
raise ValueError('$ELASTICSEARCH_HOST is not defined.')
elasticsearch_username = "elastic"
#elasticsearch_username = os.environ.get('ELASTICSEARCH_USERNAME')
#elasticsearch_password = os.environ.get('ELASTICSEARCH_PASSWORD')
elasticsearch_password = "3g53NNL+Xusi3yzEV+Od"
#os.environ.get('ELASTICSEARCH_PASSWORD')
if elasticsearch_username and elasticsearch_password:
http_auth = [elasticsearch_username, elasticsearch_password]
else:
http_auth = None
# es = Elasticsearch(
# hosts=[elasticsearch_host],
# http_auth=http_auth,
# #time_out=30
# )
#print("type of elastic_port ", type(elasticsearch_port))
#es = Elasticsearch([{'host': elasticsearch_host, 'port': elasticsearch_port, "scheme": "https"}], http_auth=http_auth, ca_certs="/home/ubuntu/test/indexer/web_indexers/http_ca.crt")
# WOrking in the second step
es = Elasticsearch([{'host': '145.100.135.113', 'port': 9200, "scheme": "https"}], http_auth=http_auth, ca_certs="/home/ubuntu/Development/test/indexer/web_indexers/http_ca.crt")
#es = Elasticsearch([{'host': 'localhost', 'port': 9200, "scheme": "http"}], http_auth=http_auth, verify_certs=False)
#verify_certs=False
print("Printing ping and information*****", es.ping())
print(es.info())
elasticsearch_host = "https://localhost:9200"
#os.environ.get('ELASTICSEARCH_HOST')
if elasticsearch_host is None:
raise ValueError('$ELASTICSEARCH_HOST is not defined.')
elasticsearch_username = "elastic"
#os.environ.get('ELASTICSEARCH_USERNAME')
elasticsearch_password = "3g53NNL+Xusi3yzEV+Od"
#os.environ.get('ELASTICSEARCH_PASSWORD')
if elasticsearch_username and elasticsearch_password:
http_auth = [elasticsearch_username, elasticsearch_password]
else:
http_auth = None
# es = Elasticsearch(
# hosts=[elasticsearch_host],
# http_auth=http_auth,
# #time_out=30
# )
es = Elasticsearch([{'host': 'localhost', 'port': 9200, "scheme": "https"}], http_auth=http_auth, ca_certs="/home/ubuntu/test/indexer/web_indexers/http_ca.crt")
#es = Elasticsearch([{'host': 'localhost', 'port': 9200, "scheme": "http"}], http_auth=http_auth, verify_certs=False)
#
"""
from elasticsearch import Elasticsearch
# # Define the connection details
# es = Elasticsearch(
# "https://lifewatch.lab.uvalight.net/es-nafis/",
# http_auth=("elastic", "otwVzERILUVxDb090WBJoh56WTFFT8cT"),
# verify_certs=False # Use False only if you trust the certificate and know it's secure
# )
# # Check if the connection is successful by pinging the ES instance
# if es.ping():
# print("Connected to Elasticsearch")
# else:
# print("Could not connect to Elasticsearch")
import kaggle
try:
query = "data" # Broader query
page = 1
kernel_list = kaggle.api.kernels_list(search=query, page=page)
if kernel_list:
for kernel in kernel_list:
print(kernel.ref)
else:
print("No kernels found for the query.")
except kaggle.rest.ApiException as e:
print(f"API Exception: {e}")