I'm trying to use the 'x unified' hovermode in my plot
Here's the (relevant) code:
fig.update_traces(
mode="markers+lines",)
fig.update_layout(
hovermode='x unified')
In my localhost, I see:
But in my server (deployed on AWS), I see:
Any suggestions?
Related
Unfortulately, I cant produce a reproduceable example because this works on by dev machine but not on another. it should be asimple flex table on slides
What could be causing this in officeR/flextable
Error in doc_parse_raw(x, encoding = encoding, base_url = base_url, as_html = as_html, :
StartTag: invalid element name [68]
Calls: get_top_and_bottom_slides ... as_xml_document.character -> read_xml.raw -> doc_parse_raw
options(encoding="UTF-8")
Sys.setlocale("LC_ALL", 'en_US.UTF-8')
solves the issue
The problem was the library was encountering different charcters when the encoding was not right.
I'm running gunicorn as:
guiconrn --bind=0.0.0.0:5000 --log-file gunicorn.log myapp:app
Seems like gunicorn.log keeps growing. Is there a way to specify a max size of the log file, so that if it reaches max size, it'll just override it.
Thanks!!
TLDR;
I believe there might be a "python only" solution using the rotating file handler provided in the internal lib of python. (at least 3.10)
To test
I created a pet project for you to fiddle with:
Create the following python file
test_logs.py
import logging
import logging.config
import time
logging.config.fileConfig(fname='log.conf', disable_existing_loggers=False)
while True:
time.sleep(0.5)
logging.debug('This is a debug message')
logging.info('This is an info message')
logging.warning('This is a warning message')
logging.error('This is an error message')
logging.critical('This is a critical message')
Create the following config file
log.conf
[loggers]
keys=root
[handlers]
keys=rotatingHandler
[formatters]
keys=sampleFormatter
[logger_root]
level=DEBUG
handlers=rotatingHandler
[handler_rotatingHandler]
class=logging.handlers.RotatingFileHandler
level=DEBUG
formatter=sampleFormatter
args=('./logs/logs.log', 'a', 1200, 1, 'utf-8')
[formatter_sampleFormatter]
format=%(asctime)s - %(name)s - %(levelname)s - %(message)s
Create the ./logs directory
Run python test_logs.py
To Understand
As you may have noticed already, the setting that allow for this behaviour is logging.handlers.RotatingFileHandler and the provided arguments args=('./logs/logs.log', 'a', 1200, 10, 'utf-8')
RotatingFileHandler is a stream handler writing to a file. That allow for 2 parameters of interest:
maxBytes set arbitrarily at 1200
backupCount set arbitrarily to 10
The behaviour is that upon reaching 1200 Bytes in size, the file is closed, renamed to /logs/logs.log.<a number up to 10> and a new file is opened.
BUT is any of maxBytes or backupCount is 0. No rotation is done !
In Gunicorn
As per the documentation you can feed a config file.
This could look like:
guiconrn --bind=0.0.0.0:5000 --log-config log.conf myapp:app
You will need to tweak it to your existing setup.
On Ubuntu/Linux, suggest to use logrotate to manage your logs, do like this: https://stackoverflow.com/a/55643449/6705684
Since Python>3.3, With RotatingFileHandler, here is my solution(MacOS/Windows/Linux/...) :
import os
import logging
from logging.handlers import RotatingFileHandler
fmt_str = '[%(asctime)s]%(module)s - %(funcName)s - %(message)s'
fmt = logging.Formatter(fmt_str)
def rotating_logger(name, fmt=fmt,
level=logging.INFO,
logfile='.log',
maxBytes=10 * 1024 * 1024,
backupCount=5,
**kwargs
):
logger = logging.getLogger(name)
hdl = RotatingFileHandler(logfile, maxBytes=maxBytes, backupCount=backupCount)
hdl.setLevel(level)
hdl.setFormatter(fmt)
logger.addHandler(hdl)
return logger
more refer:
https://docs.python.org/3/library/logging.handlers.html#rotatingfilehandler
I am having a group_var/all file whose starting lines look exactly like this :
##################################
['./roles/openssh/defaults',
'./roles/rsyslog/defaults',
'./roles/tomcat8/defaults',
'./roles/oracle_java/defaults',
'./roles/psp_db/defaults',
'./roles/provision_kill_instance/defaults',
'./roles/kill_app/defaults',
'./roles/base/defaults',
'./roles/ntp/defaults']
##################################
base_google_dns_enabled: false
when i run it as ansible-playbook provision_aws.yml it throws a error :
ERROR: Syntax Error while loading YAML script, /home/nsingh/ansible-psportal/group_vars/all
Note: The error may actually appear before this position: line 13, column 1
base_google_dns_enabled: false
According to my diagnosis , this is because of the things inside [] , even if i put this at the end of my group_vars i encounter something similar. Any Help Would be highly appreciated.
Your syntax looks incorrect. Try:
---
myroles:
- './roles/openssh/defaults'
- './roles/rsyslog/defaults'
- './roles/tomcat8/defaults'
- './roles/oracle_java/defaults'
- './roles/psp_db/defaults'
- './roles/provision_kill_instance/defaults'
- './roles/kill_app/defaults'
- './roles/base/defaults'
- './roles/ntp/defaults'
base_google_dns_enabled: false
The following code works as expected.
import boto.ec2
conn = boto.ec2.connect_to_region("us-east-1", aws_access_key_id='xxx', aws_secret_access_key='zzz')
sg = conn.create_security_group('test_delete', 'description')
auth = conn.authorize_security_group(sg.name, None, None, ip_protocol='tcp', from_port='22', to_port='22', cidr_ip='0.0.0.0/0')
I can select "All traffic" option from user interface. There is no equivalent here in boto.
I am aware of the security risks involved, but for some reason I want to open all ports (to / from) for all traffic using boto.
use 'IpProtocol': '-1' for "All traffic" option, see below code for details.
def create_ingress_rules (credentials=None,securitygroupid=None, region_name=None):
print("3-Start creating ingress rule(s)...")
create_ingress_rules_handler = \
boto3.client('ec2',
aws_access_key_id=credentials['AccessKeyId'],
aws_secret_access_key=credentials['SecretAccessKey'],
aws_session_token=credentials['SessionToken'],
region_name=region_name)
try:
data = create_ingress_rules_handler.authorize_security_group_ingress(
GroupId=securitygroupid,
IpPermissions=[
{'IpProtocol': '-1',
'FromPort': 0,
'ToPort': 65535,
'IpRanges': [{'CidrIp': '0.0.0.0/0','Description': 'Temporary inbound rule for Guardrail Testing'}]}
])
print('Complete creating Ingress rule...')
except ClientError as e:
print(e)
I think you just have to specify the min and max values for a port number. Since it is a 16-bit value, the value can range from 0 to 65535. So:
auth = conn.authorize_security_group(sg.name, None, None, ip_protocol='tcp', from_port=0, to_port=65535, cidr_ip='0.0.0.0/0')
Should allow traffic on all ports for the TCP protocol.
This might be a duplicate- but I couldn't find something to solve this problem.
I'm using httpGET() to call the google directions API.
Packages:
require(RCurl)
require(rjson)
require(gooJSON)
the code is:
url = "http://maps.googleapis.com/maps/api/directions/json?origin=12.9673293,77.7173975&destination=12.9373613,77.700985&waypoints=optimize:true|12.9723379,77.7117611|12.9922162,77.715895|12.9629354,77.7122996&sensor=false"
routeJSON = httpGET(url= url)
routeList = fromJSON(routeJSON)
I get:
Error in fromJSON(routeJSON) :
unexpected escaped character '\]' at pos 18
I wrote the JSON to a file and copied it to jsoneditoronline.com. I got:
Error: Parse error on line 51:
... "points" : "qscnA_djyMj#kAT[\]\
-----------------------^
Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[', got 'undefined'
validated by jsonlint
But it works when I put the URL into the browser and copy the output to jsoneditoronline.
Any idea why it is happening and/or how to circumvent it?
EDIT: I tried gooJSON, but it seems it does not support the maps API V3.
> goomap(url)
$Status
$Status$code
[1] 610
$Status$request
[1] "geocode"
$Status$error_message
[1] "The Geocoding API v2 has been turned down on September 9th, 2013. The Geocoding API v3 should be used now. Learn more at https://developers.google.com/maps/documentation/geocoding/"
The following works fine for me:
require(rjson)
url = "http://maps.googleapis.com/maps/api/directions/json?origin=12.9673293,77.7173975&destination=12.9373613,77.700985&waypoints=optimize:true|12.9723379,77.7117611|12.9922162,77.715895|12.9629354,77.7122996&sensor=false"
fromJSON(file=url)
However, if there is invalid json data, one can call
fromJSON(url, unexpected.escape="keep")
to to treat the escaped character as normal character (e.g. \] becomes ])