hi im new to python cherrypy framework.
how to set up config file to use mysql database object.
myapp.conf contain
[global]
server.socket_host = "127.0.0.1"
server.socket_port = 8080
server.thread_pool = 10
server.thread_pool = 10
[Databases]
driver: "mysql"
host: "localhost"
username: "testusers"
password: "bharti"
dbtable: "employe"
[/path]
response.timeout: 6000
i want to use myapp conf file to set database parameter in my application code.
how to access or use conf file...please help me out
try this...
server.conf:
[Database]
host: '192.168.0.1'
user: 'user'
passwd: 'passwd'
port: 3306
db: 'data'
and access the settings this way in your python file:
from MySQLdb.cursors import DictCursor
MySQLconnection = MySQLdb.connect(host=cherrypy.request.app.config['Database']['host'],
passwd=cherrypy.request.app.config['Database']['passwd'],
db=cherrypy.request.app.config['Database']['db'],
user=cherrypy.request.app.config['Database']['user'],
port=cherrypy.request.app.config['Database']['port'],
cursorclass=DictCursor)
MySQLcursor = MySQLconnection.cursor()
Hope this helps!
Andrew
Related
I'm trying to set an email sender (for example recovery password). I already set with a Gmail and Outlook address mail and it's work!
Now i nedd to configure an Aruba hostmail.
this is my deployment.toml configuration module
[output_adapter.email]
from_address= "****#aruba.it"
username= "*****#****.it"
password= "******"
hostname= "smtps.aruba.it"
port= 465
enable_start_tls= true
enable_authentication= true
signature = "****"
[output_adapter.email.custom_properties]
"mail.smtp.ssl.protocols"="TLSv1.2"
"mail.transport.protocol"="smtps"
Logs return
ERROR {org.wso2.carbon.event.output.adapter.email.EmailEventAdapter} - Event dropped at Output Adapter 'EmailPublisher' for tenant id '-1234', Error in message format, Could not connect to SMTP host: smtps.aruba.it, port: 465, response: -1 javax.mail.MessagingException: Could not connect to SMTP host: smtps.aruba.it, port: 465, response: -1
I tried with smpts and smpt (it should be the same port 465).
Can you tell me if it's not supported or something?
THanks, i really need help :(
I fixed it by adding these properties in deployment.toml file below this modules:
[output_adapter.email]
from_address= "***#aruba.it"
username= "****"
password= "****!"
hostname= "smtps.aruba.it"
port= 465
enable_start_tls= true
enable_authentication= true
signature = "WSO2"
[output_adapter.email.custom_properties]
"mail.smtp.ssl.protocols"="TLSv1.2"
"mail.smtp.debug"="true"
"mail.smtp.socketFactory.port"="465"
"mail.smtp.socketFactory.class"="javax.net.ssl.SSLSocketFactory"
"mail.smtp.socketFactory.fallback"="false"
I have long time seeking for a solution to set a proxy for my Django application.
1st I am using Django==2.0 and I run it in Windows Server 2016 in a local network that uses a Proxy to connect 10.37.235.99 and Port 80.
and I'm deploying the application using nginx-1.20.1
I have to scrape a data as
http_proxy = "10.37.235.99:80"
https_proxy = "10.37.235.99:80"
ftp_proxy = "10.37.235.99:80"
proxyDict = {
"http" : http_proxy,
"https" : https_proxy,
"ftp" : ftp_proxy
}
import socket
if socket.gethostname() == "localhost":
os.environ["PROXIES"] = proxyDict
else:
os.environ["PROXIES"] = {}
URL='my_site.com'
page = requests.get(URL)
print(page)
I tried many solutions on the internet but no way!
Working with django : Proxy setup
when I remove the proxy configuration and I use Psiphon3(with proxy) everything works perfectly.
is there any solution?
I'm trying to get an AWS/Lightsail Debian server automatically renewing certificates with certbot. My DNS is with Namecheap.
I'm follow the steps on https://blog.bryanroessler.com/2019-02-09-automatic-certbot-namecheap-acme-dns/ and https://blog.bryanroessler.com/2019-02-09-automatic-certbot-namecheap-acme-dns/. I keep getting a no-permission error.
I run:
sudo certbot certonly -d "*.example.com" --agree-tos --manual-public-ip-logging-ok --server https://acme-v02.api.letsencrypt.org/directory --preferred-challenges dns --manual --manual-auth-hook /etc/letsencrypt/acme-dns-auth.py --debug-challenges
I see:
Failed authorization procedure. example.com (dns-01): urn:ietf:params:acme:error:unauthorized :: The client lacks sufficient authorization :: No TXT record found at _acme-challenge.example.com
It says I need to open port 53. I followed Amazon's Lightsail instructions. Neither iptables nor ufw seems to be installed. When I nmap my machine, I don't see 53. I actually installed ufw for lack of a good idea, to no avail.
My /etc/acme-dns/config.cfg is as follows:
#/etc/acme-dns/config.cfg
[general]
# DNS interface
listen = ":53"
protocol = "udp"
# domain name to serve the requests off of
domain = "acme.example.com"
# zone name server
nsname = "ns1.acme.example.com"
# admin email address, where # is substituted with .
nsadmin = "example.example.com"
# predefined records served in addition to the TXT
records = [
"acme.example.com. A <public ip>",
"ns1.acme.example.com. A <public ip>",
"acme.example.com. NS ns1.acme.example.com.",
]
debug = false
[database]
engine = "sqlite3"
connection = "/var/lib/acme-dns/acme-dns.db"
[api]
api_domain = ""
ip = "127.0.0.1"
disable_registration = false
autocert_port = "80"
port = "8082"
tls = "none"
corsorigins = [
"*"
]
use_header = false
header_name = "X-Forwarded-For"
[logconfig]
loglevel = "debug"
logtype = "stdout"
logformat = "text"
For the listen value, I also tried 127.0.0.1:53 and :53
The settings portion of /etc/letsencrypt/acme-dns-auth.py:
# URL to acme-dns instance
ACMEDNS_URL = "http://127.0.0.1:8082"
# Path for acme-dns credential storage
STORAGE_PATH = "/etc/letsencrypt/acmedns.json"
# Whitelist for address ranges to allow the updates from
# Example: ALLOW_FROM = ["192.168.10.0/24", "::1/128"]
ALLOW_FROM = []
# Force re-registration. Overwrites the already existing acme-dns accounts.
FORCE_REGISTER = False
Thanks for any help you can provide.
If you don't wish to maintain your own acme DNS server, I built and use this script to automatically renew NameCheap wildcard certs with certbot. I hope it helps:
https://github.com/scribe777/letsencrypt-namecheap-dns-auth
I am trying to connect to ejabberd. Version of ejabberd is 18. i changed ejabberd.yml
module: ejabberd_http
request_handlers:
"/ws": ejabberd_http_ws
"/bosh": mod_bosh
"/api": mod_http_api
## "/pub/archive": mod_http_fileserver
web_admin: true
http_bind: true
http_poll: true
## register: true
captcha: true
when i am using strophe to connect by
var conn = new Strophe.Connection('http://localhost:5280/http-bind');
it says connection attempt failed and connection timeout.
Any solutions please ??
var conn = new Strophe.Connection('http://localhost:5280/http-bind');
You are requesting the "/http-bind" path, but ejabberd is listening in "/bosh". Change your quety, or change to config, so these paths match.
Currently I have a "State" model and following config details in shards.yml.
I am checking the following in "development" environment.
octopus:
environments:
- development
- staging
- production
replicated: true
fully_replicated: true
development:
slave1:
host: 192.168.5.130
adapter: mysql2
database: mydb
username: user
password: Password
reconnect: false
staging:
slave1:
host: 192.168.1.2
adapter: mysql2
database: server_db
username: admin
password: fake_staging_password
reconnect: false
production:
slave1:
host: 192.168.1.5
adapter: mysql2
database: production_db_name
username: admin
password: fake_production_password
reconnect: true
When ever I issue State.all or any active record query, I see the same SQL statment is sent to server 2 times
For example State.count sends the following SQL two times.
[Shard: slave1] (1.5ms) SELECT COUNT(*) FROM `states`
[Shard: slave1] (2.1ms) SELECT COUNT(*) FROM `states`
=> 35
Is this normal? or I have any issue in settings?
I think you're supposed to place either replicated: true or fully_replicated: true
Not both.