[issue44333] Segmentation fault

2021-06-07 Thread Kuldeep Daksh


New submission from Kuldeep Daksh :

I am getting Segmentation fault when i run server.starttls() method.

--
components: Library (Lib)
files: segment_fault.png
messages: 395251
nosy: mechatronickuldeep
priority: normal
severity: normal
status: open
title: Segmentation fault
versions: Python 3.6
Added file: https://bugs.python.org/file50094/segment_fault.png

___
Python tracker 
<https://bugs.python.org/issue44333>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44333] Segmentation fault

2021-06-07 Thread Kuldeep Daksh


Kuldeep Daksh  added the comment:

I am not getting this error when I run same code in other window. I am not
able to get why this is happening.

On Mon, Jun 7, 2021, 14:20 Eric V. Smith  wrote:

>
> Eric V. Smith  added the comment:
>
> Python 3.6 is no longer supported. Please try to reproduce this with
> python 3.8 or 3.9.
>
> Without seeing the code that causes the failure, it's not possible for us
> to provide any help. Please try to reproduce the code with the smallest
> possible example and include the code here.
>
> Please do not post images, as they make it impossible for us to copy and
> paste from the file you upload. They also make it difficult for visually
> impaired people to read them.
>
> --
> nosy: +eric.smith
> status: open -> pending
>
> ___
> Python tracker 
> <https://bugs.python.org/issue44333>
> ___
>

--
status: pending -> open

___
Python tracker 
<https://bugs.python.org/issue44333>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44333] Segmentation fault

2021-06-07 Thread Kuldeep Daksh


Kuldeep Daksh  added the comment:

I am having lunch right now.after lunch I will give you the information.

On Mon, Jun 7, 2021, 14:42 Eric V. Smith  wrote:

>
> Eric V. Smith  added the comment:
>
> If you can't provide any more information, we can't help you and I'll have
> to close this issue.
>
> --
>
> ___
> Python tracker 
> <https://bugs.python.org/issue44333>
> ___
>

--

___
Python tracker 
<https://bugs.python.org/issue44333>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44333] Segmentation fault

2021-06-07 Thread Kuldeep Daksh

Kuldeep Daksh  added the comment:

I run same code on different window with python3.6. at other place smtp
working in a right way but as I run it in my project its still giving the
error. please find the attachment of my code.

On Mon, 7 Jun 2021 at 14:44, Kuldeep Daksh  wrote:

>
> Kuldeep Daksh  added the comment:
>
> I am having lunch right now.after lunch I will give you the information.
>
> On Mon, Jun 7, 2021, 14:42 Eric V. Smith  wrote:
>
> >
> > Eric V. Smith  added the comment:
> >
> > If you can't provide any more information, we can't help you and I'll
> have
> > to close this issue.
> >
> > --
> >
> > ___
> > Python tracker 
> > <https://bugs.python.org/issue44333>
> > ___
> >
>
> --
>
> ___
> Python tracker 
> <https://bugs.python.org/issue44333>
> ___
>

--
Added file: https://bugs.python.org/file50095/alert_emailer.py

___
Python tracker 
<https://bugs.python.org/issue44333>
___import os
import inspect
import logging
import smtplib,ssl
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from jinja2 import FileSystemLoader, Environment

from alerts.models.alert_rule import AlertRule
from alerts.models.user import User
from alerts.models.asset import Asset
from alerts.repositories.user_alert_email_count_repo import 
UserAlertEmailCountRepository


class AlertEmailer:
__instance = None
__config = None
__from = None
__pwd = None
__server = None
__image_url = 
'https://s3-us-west-2.amazonaws.com/s3-us-west-2.amazonaws.com.public-images/alert.png'
__user_email_count_repo = None

@staticmethod
def getInstance(config):
if AlertEmailer.__instance == None:
AlertEmailer(config)
return AlertEmailer.__instance

def __init__(self, config):
self.logger = logging.getLogger(__name__)
if self.__config is None:
self.__config = config
self.context = ssl.create_default_context()
with smtplib.SMTP_SSL("smtp.gmail.com", 465, context=self.context) 
as server:

self.__from = config.email_from
self.__pwd = config.email_from_pwd
server.login(self.__from, self.__pwd)
if self.__user_email_count_repo is None:
self.__user_email_count_repo = 
UserAlertEmailCountRepository(self.__config)
if AlertEmailer.__instance is not None:
raise Exception("This class is a singleton class!")
else:
AlertEmailer.__instance = self

def send_email(self, title: str, al_msg: str, alert_rule: AlertRule):
users = alert_rule.get_users()
if len(users) > 0:
recipients = []
for user in users:
if user.is_email_alerts_enabled():
self.logger.info(user.get_email())
if alert_rule.is_critical():
recipients.append(user.get_email())
elif self.__should_send_alert_email(user, alert_rule):
recipients.append(user.get_email())
if len(recipients) > 0:
self.__send_default(title, al_msg, recipients)
else:
self.logger.info("No recipient for sending email.")

def send_fault_alert_email(self, title: str, al_msg: str, asset: Asset):
users = ["ksi...@sensegrow.com"]
if (len(users) > 0):
recipients = ["ksi...@sensegrow.com"]
# for user in users:
# self.logger.info(user.get_email())
# recipients.append(user.get_email())

self.__send_default(title, al_msg, recipients)
else:
self.logger.info("No recipient for sending email.")

def __should_send_alert_email(self, user: User, alert_rule: AlertRule):
try:
alert_count = 
self.__user_email_count_repo.get_alert_rule_count(user, alert_rule)
alert_group_count = 
self.__user_email_count_repo.get_alert_rule_group_count(user, alert_rule)
if user.get_alert_msg_rate_limit_throttle() > alert_count:
if alert_group_count < 1:
self.__user_email_count_repo.update_count(user, alert_rule);
return True
return False
except Exception as ex:
self.logger.error(ex)
return False

def __send_default(self, title: str, al_msg: str, recipients):
current_dir = 
os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe(
file_name = 

[issue44333] Segmentation fault

2021-06-07 Thread Kuldeep Daksh

Kuldeep Daksh  added the comment:

Please ignore previous attachment and find new one.

On Mon, 7 Jun 2021 at 15:20, Kuldeep Daksh 
wrote:

> I run same code on different window with python3.6. at other place smtp
> working in a right way but as I run it in my project its still giving the
> error. please find the attachment of my code.
>
> On Mon, 7 Jun 2021 at 14:44, Kuldeep Daksh  wrote:
>
>>
>> Kuldeep Daksh  added the comment:
>>
>> I am having lunch right now.after lunch I will give you the information.
>>
>> On Mon, Jun 7, 2021, 14:42 Eric V. Smith  wrote:
>>
>> >
>> > Eric V. Smith  added the comment:
>> >
>> > If you can't provide any more information, we can't help you and I'll
>> have
>> > to close this issue.
>> >
>> > --
>> >
>> > ___
>> > Python tracker 
>> > <https://bugs.python.org/issue44333>
>> > ___
>> >
>>
>> --
>>
>> ___
>> Python tracker 
>> <https://bugs.python.org/issue44333>
>> ___
>>
>

--
Added file: https://bugs.python.org/file50096/alert_emailer.py

___
Python tracker 
<https://bugs.python.org/issue44333>
___import os
import inspect
import logging
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from jinja2 import FileSystemLoader, Environment

from alerts.models.alert_rule import AlertRule
from alerts.models.user import User
from alerts.models.asset import Asset
from alerts.repositories.user_alert_email_count_repo import 
UserAlertEmailCountRepository

class AlertEmailer:
__instance = None
__config = None
__from = None
__pwd = None
__server = None
__image_url = 
'https://s3-us-west-2.amazonaws.com/s3-us-west-2.amazonaws.com.public-images/alert.png'
__user_email_count_repo = None


@staticmethod
def getInstance(config):
if AlertEmailer.__instance == None:
AlertEmailer(config)
return AlertEmailer.__instance

def __init__(self, config):
self.logger = logging.getLogger(__name__)
if self.__config is None:
self.__config = config
if self.__server is None:
self.__server = smtplib.SMTP('smtp.gmail.com', 587)
self.__server.starttls()
self.__from = config.email_from
self.__pwd = config.email_from_pwd
self.__server.login(self.__from, self.__pwd)
if self.__user_email_count_repo is None:
self.__user_email_count_repo = 
UserAlertEmailCountRepository(self.__config)
if AlertEmailer.__instance is not None:
raise Exception("This class is a singleton class!")
else:
AlertEmailer.__instance = self

def send_email(self, title: str, al_msg: str, alert_rule: AlertRule):
users = alert_rule.get_users()
if len(users) > 0:
recipients = []
for user in users:
if user.is_email_alerts_enabled():
self.logger.info(user.get_email())
if alert_rule.is_critical():
recipients.append(user.get_email())
elif self.__should_send_alert_email(user, alert_rule):
recipients.append(user.get_email())
if len(recipients) > 0:
self.__send_default(title, al_msg, recipients)
else:
self.logger.info("No recipient for sending email.")

def send_fault_alert_email(self, title: str, al_msg: str, asset: Asset):
users = ["ksi...@sensegrow.com"]
if (len(users) > 0):
recipients = ["ksi...@sensegrow.com"]
# for user in users:
# self.logger.info(user.get_email())
# recipients.append(user.get_email())

self.__send_default(title, al_msg, recipients)
else:
self.logger.info("No recipient for sending email.")

def __should_send_alert_email(self, user: User, alert_rule: AlertRule):
try:
alert_count = 
self.__user_email_count_repo.get_alert_rule_count(user, alert_rule)
alert_group_count = 
self.__user_email_count_repo.get_alert_rule_group_count(user, alert_rule)
if user.get_alert_msg_rate_limit_throttle() > alert_count:
if alert_group_count < 1:
self.__user_email_count_repo.update_count(user, alert_rule);
return True
return False
except Exc