[MERGE] forward port of branch saas-6 up to 6c6a9f3
This commit is contained in:
@@ -101,11 +101,11 @@
|
|||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<div style="border-top-left-radius:3px;border-top-right-radius:3px;font-size:12px;border-collapse:separate;text-align:center;font-weight:bold;color:#ffffff;width:130px;min-height: 18px;border-color:#ffffff;background:#8a89ba;padding-top: 4px;">${object.event_id.get_interval(object.event_id.start, 'dayname', tz=object.partner_id.tz)}</div>
|
<div style="border-top-left-radius:3px;border-top-right-radius:3px;font-size:12px;border-collapse:separate;text-align:center;font-weight:bold;color:#ffffff;width:130px;min-height: 18px;border-color:#ffffff;background:#8a89ba;padding-top: 4px;">${object.event_id.get_interval(object.event_id.start, 'dayname', tz=object.partner_id.tz if not object.event_id.allday else None)}</div>
|
||||||
<div style="font-size:48px;min-height:auto;font-weight:bold;text-align:center;color: #5F5F5F;background-color: #E1E2F8;width: 130px;">
|
<div style="font-size:48px;min-height:auto;font-weight:bold;text-align:center;color: #5F5F5F;background-color: #E1E2F8;width: 130px;">
|
||||||
${object.event_id.get_interval(object.event_id.start,'day', tz=object.partner_id.tz)}
|
${object.event_id.get_interval(object.event_id.start,'day', tz=object.partner_id.tz if not object.event_id.allday else None)}
|
||||||
</div>
|
</div>
|
||||||
<div style='font-size:12px;text-align:center;font-weight:bold;color:#ffffff;background-color:#8a89ba'>${object.event_id.get_interval(object.event_id.start, 'month', tz=object.partner_id.tz)}</div>
|
<div style='font-size:12px;text-align:center;font-weight:bold;color:#ffffff;background-color:#8a89ba'>${object.event_id.get_interval(object.event_id.start, 'month', tz=object.partner_id.tz if not object.event_id.allday else None)}</div>
|
||||||
<div style="border-collapse:separate;color:#8a89ba;text-align:center;width: 128px;font-size:12px;border-bottom-right-radius:3px;font-weight:bold;border:1px solid;border-bottom-left-radius:3px;">${not object.event_id.allday and object.event_id.get_interval(object.event_id.start, 'time', tz=object.partner_id.tz) or ''}</div>
|
<div style="border-collapse:separate;color:#8a89ba;text-align:center;width: 128px;font-size:12px;border-bottom-right-radius:3px;font-weight:bold;border:1px solid;border-bottom-left-radius:3px;">${not object.event_id.allday and object.event_id.get_interval(object.event_id.start, 'time', tz=object.partner_id.tz) or ''}</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@@ -226,11 +226,11 @@
|
|||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<div style="border-top-left-radius:3px;border-top-right-radius:3px;font-size:12px;border-collapse:separate;text-align:center;font-weight:bold;color:#ffffff;width:130px;min-height: 18px;border-color:#ffffff;background:#8a89ba;padding-top: 4px;">${object.event_id.get_interval(object.event_id.start, 'dayname', tz=object.partner_id.tz)}</div>
|
<div style="border-top-left-radius:3px;border-top-right-radius:3px;font-size:12px;border-collapse:separate;text-align:center;font-weight:bold;color:#ffffff;width:130px;min-height: 18px;border-color:#ffffff;background:#8a89ba;padding-top: 4px;">${object.event_id.get_interval(object.event_id.start, 'dayname', tz=object.partner_id.tz if not object.event_id.allday else None)}</div>
|
||||||
<div style="font-size:48px;min-height:auto;font-weight:bold;text-align:center;color: #5F5F5F;background-color: #E1E2F8;width: 130px;">
|
<div style="font-size:48px;min-height:auto;font-weight:bold;text-align:center;color: #5F5F5F;background-color: #E1E2F8;width: 130px;">
|
||||||
${object.event_id.get_interval(object.event_id.start,'day', tz=object.partner_id.tz)}
|
${object.event_id.get_interval(object.event_id.start,'day', tz=object.partner_id.tz if not object.event_id.allday else None)}
|
||||||
</div>
|
</div>
|
||||||
<div style='font-size:12px;text-align:center;font-weight:bold;color:#ffffff;background-color:#8a89ba'>${object.event_id.get_interval(object.event_id.start, 'month', tz=object.partner_id.tz)}</div>
|
<div style='font-size:12px;text-align:center;font-weight:bold;color:#ffffff;background-color:#8a89ba'>${object.event_id.get_interval(object.event_id.start, 'month', tz=object.partner_id.tz if not object.event_id.allday else None)}</div>
|
||||||
<div style="border-collapse:separate;color:#8a89ba;text-align:center;width: 128px;font-size:12px;border-bottom-right-radius:3px;font-weight:bold;border:1px solid;border-bottom-left-radius:3px;">${not object.event_id.allday and object.event_id.get_interval(object.event_id.start, 'time', tz=object.partner_id.tz) or ''}</div>
|
<div style="border-collapse:separate;color:#8a89ba;text-align:center;width: 128px;font-size:12px;border-bottom-right-radius:3px;font-weight:bold;border:1px solid;border-bottom-left-radius:3px;">${not object.event_id.allday and object.event_id.get_interval(object.event_id.start, 'time', tz=object.partner_id.tz) or ''}</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@@ -350,11 +350,11 @@
|
|||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<div style="border-top-left-radius:3px;border-top-right-radius:3px;font-size:12px;border-collapse:separate;text-align:center;font-weight:bold;color:#ffffff;width:130px;min-height: 18px;border-color:#ffffff;background:#8a89ba;padding-top: 4px;">${object.event_id.get_interval(object.event_id.start, 'dayname', tz=object.partner_id.tz)}</div>
|
<div style="border-top-left-radius:3px;border-top-right-radius:3px;font-size:12px;border-collapse:separate;text-align:center;font-weight:bold;color:#ffffff;width:130px;min-height: 18px;border-color:#ffffff;background:#8a89ba;padding-top: 4px;">${object.event_id.get_interval(object.event_id.start, 'dayname', tz=object.partner_id.tz if not object.event_id.allday else None)}</div>
|
||||||
<div style="font-size:48px;min-height:auto;font-weight:bold;text-align:center;color: #5F5F5F;background-color: #E1E2F8;width: 130px;">
|
<div style="font-size:48px;min-height:auto;font-weight:bold;text-align:center;color: #5F5F5F;background-color: #E1E2F8;width: 130px;">
|
||||||
${object.event_id.get_interval(object.event_id.start,'day', tz=object.partner_id.tz)}
|
${object.event_id.get_interval(object.event_id.start,'day', tz=object.partner_id.tz if not object.event_id.allday else None)}
|
||||||
</div>
|
</div>
|
||||||
<div style='font-size:12px;text-align:center;font-weight:bold;color:#ffffff;background-color:#8a89ba'>${object.event_id.get_interval(object.event_id.start, 'month', tz=object.partner_id.tz)}</div>
|
<div style='font-size:12px;text-align:center;font-weight:bold;color:#ffffff;background-color:#8a89ba'>${object.event_id.get_interval(object.event_id.start, 'month', tz=object.partner_id.tz if not object.event_id.allday else None)}</div>
|
||||||
<div style="border-collapse:separate;color:#8a89ba;text-align:center;width: 128px;font-size:12px;border-bottom-right-radius:3px;font-weight:bold;border:1px solid;border-bottom-left-radius:3px;">${not object.event_id.allday and object.event_id.get_interval(object.event_id.start, 'time', tz=object.partner_id.tz) or ''}</div>
|
<div style="border-collapse:separate;color:#8a89ba;text-align:center;width: 128px;font-size:12px;border-bottom-right-radius:3px;font-weight:bold;border:1px solid;border-bottom-left-radius:3px;">${not object.event_id.allday and object.event_id.get_interval(object.event_id.start, 'time', tz=object.partner_id.tz) or ''}</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
@@ -306,7 +306,7 @@ class MergePartnerAutomatic(osv.TransientModel):
|
|||||||
for partner_id in partner_ids:
|
for partner_id in partner_ids:
|
||||||
child_ids = child_ids.union(set(proxy.search(cr, uid, [('id', 'child_of', [partner_id])])) - set([partner_id]))
|
child_ids = child_ids.union(set(proxy.search(cr, uid, [('id', 'child_of', [partner_id])])) - set([partner_id]))
|
||||||
if set(partner_ids).intersection(child_ids):
|
if set(partner_ids).intersection(child_ids):
|
||||||
raise osv.except_osv(_('Error'), _("You cannot merge a contact with one of his parent."))
|
raise UserError(_("You cannot merge a contact with one of his parent."))
|
||||||
|
|
||||||
if openerp.SUPERUSER_ID != uid and len(set(partner.email for partner in proxy.browse(cr, uid, partner_ids, context=context))) > 1:
|
if openerp.SUPERUSER_ID != uid and len(set(partner.email for partner in proxy.browse(cr, uid, partner_ids, context=context))) > 1:
|
||||||
raise UserError(_("All contacts must have the same email. Only the Administrator can merge contacts with different emails."))
|
raise UserError(_("All contacts must have the same email. Only the Administrator can merge contacts with different emails."))
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ access_ crm_lead_report_assign,crm.lead.report.assign,model_crm_lead_report_assi
|
|||||||
access_ crm_lead_report_assign_all,crm.lead.report.assign.all,model_crm_lead_report_assign,base.group_user,1,0,0,0
|
access_ crm_lead_report_assign_all,crm.lead.report.assign.all,model_crm_lead_report_assign,base.group_user,1,0,0,0
|
||||||
access_crm_partner_report,crm.partner.report.assign.all,model_crm_partner_report_assign,base.group_sale_salesman,1,0,0,0
|
access_crm_partner_report,crm.partner.report.assign.all,model_crm_partner_report_assign,base.group_sale_salesman,1,0,0,0
|
||||||
access_res_partner_grade,res.partner.grade,model_res_partner_grade,base.group_sale_salesman,1,1,1,0
|
access_res_partner_grade,res.partner.grade,model_res_partner_grade,base.group_sale_salesman,1,1,1,0
|
||||||
|
access_res_partner_grade_employee,res.partner.grade,model_res_partner_grade,base.group_user,1,0,0,0
|
||||||
|
access_res_partner_grade_portal,res.partner.grade,model_res_partner_grade,base.group_portal,1,0,0,0
|
||||||
access_res_partner_grade_public,res.partner.grade,model_res_partner_grade,base.group_public,1,0,0,0
|
access_res_partner_grade_public,res.partner.grade,model_res_partner_grade,base.group_public,1,0,0,0
|
||||||
access_res_partner_grade_manager,res.partner.grade.manager,model_res_partner_grade,base.group_sale_manager,1,1,1,1
|
access_res_partner_grade_manager,res.partner.grade.manager,model_res_partner_grade,base.group_sale_manager,1,1,1,1
|
||||||
access_res_partner_activation_user,res.partner.activation.user,model_res_partner_activation,base.group_user,1,0,0,0
|
access_res_partner_activation_user,res.partner.activation.user,model_res_partner_activation,base.group_user,1,0,0,0
|
||||||
|
|||||||
|
@@ -133,18 +133,36 @@ class gamification_goal_definition(osv.Model):
|
|||||||
raise UserError(_("The domain for the definition %s seems incorrect, please check it.\n\n%s") % (definition.name, msg))
|
raise UserError(_("The domain for the definition %s seems incorrect, please check it.\n\n%s") % (definition.name, msg))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def _check_model_validity(self, cr, uid, ids, context=None):
|
||||||
|
""" make sure the selected field and model are usable"""
|
||||||
|
for definition in self.browse(cr, uid, ids, context=context):
|
||||||
|
try:
|
||||||
|
if not definition.model_id or not definition.field_id:
|
||||||
|
continue
|
||||||
|
|
||||||
|
model = self.pool[definition.model_id.model]
|
||||||
|
field = model._fields[definition.field_id.name]
|
||||||
|
if not field.store:
|
||||||
|
raise UserError(
|
||||||
|
_("The model configuration for the definition %s seems incorrect, please check it.\n\n%s not stored") % (definition.name, definition.field_id.name))
|
||||||
|
except KeyError, e:
|
||||||
|
raise UserError(
|
||||||
|
_("The model configuration for the definition %s seems incorrect, please check it.\n\n%s not found") % (definition.name, e.message))
|
||||||
|
|
||||||
def create(self, cr, uid, vals, context=None):
|
def create(self, cr, uid, vals, context=None):
|
||||||
res_id = super(gamification_goal_definition, self).create(cr, uid, vals, context=context)
|
res_id = super(gamification_goal_definition, self).create(cr, uid, vals, context=context)
|
||||||
if vals.get('computation_mode') in ('count', 'sum'):
|
if vals.get('computation_mode') in ('count', 'sum'):
|
||||||
self._check_domain_validity(cr, uid, [res_id], context=context)
|
self._check_domain_validity(cr, uid, [res_id], context=context)
|
||||||
|
if vals.get('field_id'):
|
||||||
|
self._check_model_validity(cr, uid, [res_id], context=context)
|
||||||
return res_id
|
return res_id
|
||||||
|
|
||||||
def write(self, cr, uid, ids, vals, context=None):
|
def write(self, cr, uid, ids, vals, context=None):
|
||||||
res = super(gamification_goal_definition, self).write(cr, uid, ids, vals, context=context)
|
res = super(gamification_goal_definition, self).write(cr, uid, ids, vals, context=context)
|
||||||
if vals.get('computation_mode', 'count') in ('count', 'sum') and (vals.get('domain') or vals.get('model_id')):
|
if vals.get('computation_mode', 'count') in ('count', 'sum') and (vals.get('domain') or vals.get('model_id')):
|
||||||
self._check_domain_validity(cr, uid, ids, context=context)
|
self._check_domain_validity(cr, uid, ids, context=context)
|
||||||
|
if vals.get('field_id') or vals.get('model_id') or vals.get('batch_mode'):
|
||||||
|
self._check_model_validity(cr, uid, ids, context=context)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def on_change_model_id(self, cr, uid, ids, model_id, context=None):
|
def on_change_model_id(self, cr, uid, ids, model_id, context=None):
|
||||||
|
|||||||
@@ -567,14 +567,14 @@ class hr_employee(osv.Model):
|
|||||||
# Find for holidays status
|
# Find for holidays status
|
||||||
status_ids = type_obj.search(cr, uid, [('limit', '=', False)], context=context)
|
status_ids = type_obj.search(cr, uid, [('limit', '=', False)], context=context)
|
||||||
if len(status_ids) != 1 :
|
if len(status_ids) != 1 :
|
||||||
raise osv.except_osv(_('Warning!'),_("The feature behind the field 'Remaining Legal Leaves' can only be used when there is only one leave type with the option 'Allow to Override Limit' unchecked. (%s Found). Otherwise, the update is ambiguous as we cannot decide on which leave type the update has to be done. \nYou may prefer to use the classic menus 'Leave Requests' and 'Allocation Requests' located in 'Human Resources \ Leaves' to manage the leave days of the employees if the configuration does not allow to use this field.") % (len(status_ids)))
|
raise UserError(_("The feature behind the field 'Remaining Legal Leaves' can only be used when there is only one leave type with the option 'Allow to Override Limit' unchecked. (%s Found). Otherwise, the update is ambiguous as we cannot decide on which leave type the update has to be done. \nYou may prefer to use the classic menus 'Leave Requests' and 'Allocation Requests' located in 'Human Resources \ Leaves' to manage the leave days of the employees if the configuration does not allow to use this field.") % (len(status_ids)))
|
||||||
status_id = status_ids and status_ids[0] or False
|
status_id = status_ids and status_ids[0] or False
|
||||||
if not status_id:
|
if not status_id:
|
||||||
return False
|
return False
|
||||||
if diff > 0:
|
if diff > 0:
|
||||||
leave_id = holiday_obj.create(cr, uid, {'name': _('Allocation for %s') % employee.name, 'employee_id': employee.id, 'holiday_status_id': status_id, 'type': 'add', 'holiday_type': 'employee', 'number_of_days_temp': diff}, context=context)
|
leave_id = holiday_obj.create(cr, uid, {'name': _('Allocation for %s') % employee.name, 'employee_id': employee.id, 'holiday_status_id': status_id, 'type': 'add', 'holiday_type': 'employee', 'number_of_days_temp': diff}, context=context)
|
||||||
elif diff < 0:
|
elif diff < 0:
|
||||||
raise osv.except_osv(_('Warning!'), _('You cannot reduce validated allocation requests'))
|
raise UserError(_('You cannot reduce validated allocation requests'))
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
for sig in ('confirm', 'validate', 'second_validate'):
|
for sig in ('confirm', 'validate', 'second_validate'):
|
||||||
|
|||||||
@@ -18,13 +18,16 @@ class payslip_details_report(report_sxw.rml_parse):
|
|||||||
payslip_line = self.pool.get('hr.payslip.line')
|
payslip_line = self.pool.get('hr.payslip.line')
|
||||||
rule_cate_obj = self.pool.get('hr.salary.rule.category')
|
rule_cate_obj = self.pool.get('hr.salary.rule.category')
|
||||||
|
|
||||||
def get_recursive_parent(rule_categories):
|
def get_recursive_parent(current_rule_category, rule_categories = None):
|
||||||
if not rule_categories:
|
if rule_categories:
|
||||||
return []
|
rule_categories = current_rule_category | rule_categories
|
||||||
if rule_categories[0].parent_id:
|
else:
|
||||||
rule_categories = rule_categories[0].parent_id | rule_categories
|
rule_categories = current_rule_category
|
||||||
get_recursive_parent(rule_categories)
|
|
||||||
return rule_categories
|
if current_rule_category.parent_id:
|
||||||
|
return get_recursive_parent(current_rule_category.parent_id, rule_categories)
|
||||||
|
else:
|
||||||
|
return rule_categories
|
||||||
|
|
||||||
res = []
|
res = []
|
||||||
result = {}
|
result = {}
|
||||||
|
|||||||
@@ -1601,7 +1601,7 @@ class product_template(osv.osv):
|
|||||||
product_ctx = dict(context or {}, active_test=False)
|
product_ctx = dict(context or {}, active_test=False)
|
||||||
if self.search_count(cr, uid, [('id', 'in', ids), ('available_in_pos', '=', True)], context=product_ctx):
|
if self.search_count(cr, uid, [('id', 'in', ids), ('available_in_pos', '=', True)], context=product_ctx):
|
||||||
if self.pool['pos.session'].search_count(cr, uid, [('state', '!=', 'closed')], context=context):
|
if self.pool['pos.session'].search_count(cr, uid, [('state', '!=', 'closed')], context=context):
|
||||||
raise osv.except_osv(_('Error!'),
|
raise UserError(
|
||||||
_('You cannot delete a product saleable in point of sale while a session is still opened.'))
|
_('You cannot delete a product saleable in point of sale while a session is still opened.'))
|
||||||
return super(product_template, self).unlink(cr, uid, ids, context=context)
|
return super(product_template, self).unlink(cr, uid, ids, context=context)
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class stock_return_picking(osv.osv_memory):
|
|||||||
context = {}
|
context = {}
|
||||||
if context and context.get('active_ids', False):
|
if context and context.get('active_ids', False):
|
||||||
if len(context.get('active_ids')) > 1:
|
if len(context.get('active_ids')) > 1:
|
||||||
raise osv.except_osv(_('Warning!'), _("You may only return one picking at a time!"))
|
raise UserError(_("You may only return one picking at a time!"))
|
||||||
res = super(stock_return_picking, self).default_get(cr, uid, fields, context=context)
|
res = super(stock_return_picking, self).default_get(cr, uid, fields, context=context)
|
||||||
record_id = context and context.get('active_id', False) or False
|
record_id = context and context.get('active_id', False) or False
|
||||||
uom_obj = self.pool.get('product.uom')
|
uom_obj = self.pool.get('product.uom')
|
||||||
|
|||||||
@@ -277,7 +277,7 @@ class stock_quant(osv.osv):
|
|||||||
|
|
||||||
:param context: context dictionary that can explicitly mention the company to consider via the 'force_company' key
|
:param context: context dictionary that can explicitly mention the company to consider via the 'force_company' key
|
||||||
:returns: journal_id, source account, destination account, valuation account
|
:returns: journal_id, source account, destination account, valuation account
|
||||||
:raise: osv.except_osv() is any mandatory account or journal is not defined.
|
:raise: openerp.exceptions.UserError if any mandatory account or journal is not defined.
|
||||||
"""
|
"""
|
||||||
product_obj = self.pool.get('product.template')
|
product_obj = self.pool.get('product.template')
|
||||||
accounts = product_obj.browse(cr, uid, move.product_id.product_tmpl_id.id, context).get_product_accounts()
|
accounts = product_obj.browse(cr, uid, move.product_id.product_tmpl_id.id, context).get_product_accounts()
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
United States, 2016-05-25
|
||||||
|
|
||||||
|
Rock Solid Solutions, LLC <http://www.rocksolidsolutions.org> agrees to the terms of the Odoo Corporate Contributor License
|
||||||
|
Agreement v1.0.
|
||||||
|
|
||||||
|
I declare that I am authorized and able to make this agreement and sign this
|
||||||
|
declaration.
|
||||||
|
|
||||||
|
Signed,
|
||||||
|
|
||||||
|
Daniel Kauffman, Manager rocksolidsolutions@users.noreply.github.com <https://github.com/rocksolidsolutions>
|
||||||
|
|
||||||
|
List of contributors:
|
||||||
|
|
||||||
|
Daniel Kauffman rocksolidsolutions@users.noreply.github.com <https://github.com/rocksolidsolutions>
|
||||||
@@ -517,7 +517,7 @@ class res_users(osv.osv):
|
|||||||
|
|
||||||
:return: True
|
:return: True
|
||||||
:raise: openerp.exceptions.AccessDenied when old password is wrong
|
:raise: openerp.exceptions.AccessDenied when old password is wrong
|
||||||
:raise: except_osv when new password is not set or empty
|
:raise: openerp.exceptions.UserError when new password is not set or empty
|
||||||
"""
|
"""
|
||||||
self.check(cr.dbname, uid, old_passwd)
|
self.check(cr.dbname, uid, old_passwd)
|
||||||
if new_passwd:
|
if new_passwd:
|
||||||
|
|||||||
+20
-14
@@ -383,7 +383,8 @@ class PreforkServer(CommonServer):
|
|||||||
"""
|
"""
|
||||||
def __init__(self, app):
|
def __init__(self, app):
|
||||||
# config
|
# config
|
||||||
self.address = (config['xmlrpc_interface'] or '0.0.0.0', config['xmlrpc_port'])
|
self.address = config['xmlrpc'] and \
|
||||||
|
(config['xmlrpc_interface'] or '0.0.0.0', config['xmlrpc_port'])
|
||||||
self.population = config['workers']
|
self.population = config['workers']
|
||||||
self.timeout = config['limit_time_real']
|
self.timeout = config['limit_time_real']
|
||||||
self.limit_request = config['limit_request']
|
self.limit_request = config['limit_request']
|
||||||
@@ -558,12 +559,13 @@ class PreforkServer(CommonServer):
|
|||||||
signal.signal(signal.SIGQUIT, dumpstacks)
|
signal.signal(signal.SIGQUIT, dumpstacks)
|
||||||
signal.signal(signal.SIGUSR1, log_ormcache_stats)
|
signal.signal(signal.SIGUSR1, log_ormcache_stats)
|
||||||
|
|
||||||
# listen to socket
|
if self.address:
|
||||||
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
# listen to socket
|
||||||
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
self.socket.setblocking(0)
|
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||||
self.socket.bind(self.address)
|
self.socket.setblocking(0)
|
||||||
self.socket.listen(8 * self.population)
|
self.socket.bind(self.address)
|
||||||
|
self.socket.listen(8 * self.population)
|
||||||
|
|
||||||
def stop(self, graceful=True):
|
def stop(self, graceful=True):
|
||||||
if self.long_polling_pid is not None:
|
if self.long_polling_pid is not None:
|
||||||
@@ -587,7 +589,8 @@ class PreforkServer(CommonServer):
|
|||||||
_logger.info("Stopping forcefully")
|
_logger.info("Stopping forcefully")
|
||||||
for pid in self.workers.keys():
|
for pid in self.workers.keys():
|
||||||
self.worker_kill(pid, signal.SIGTERM)
|
self.worker_kill(pid, signal.SIGTERM)
|
||||||
self.socket.close()
|
if self.socket:
|
||||||
|
self.socket.close()
|
||||||
|
|
||||||
def run(self, preload, stop):
|
def run(self, preload, stop):
|
||||||
self.start()
|
self.start()
|
||||||
@@ -690,11 +693,13 @@ class Worker(object):
|
|||||||
_logger.info("Worker %s (%s) alive", self.__class__.__name__, self.pid)
|
_logger.info("Worker %s (%s) alive", self.__class__.__name__, self.pid)
|
||||||
# Reseed the random number generator
|
# Reseed the random number generator
|
||||||
random.seed()
|
random.seed()
|
||||||
# Prevent fd inherientence close_on_exec
|
if self.multi.socket:
|
||||||
flags = fcntl.fcntl(self.multi.socket, fcntl.F_GETFD) | fcntl.FD_CLOEXEC
|
# Prevent fd inheritance: close_on_exec
|
||||||
fcntl.fcntl(self.multi.socket, fcntl.F_SETFD, flags)
|
flags = fcntl.fcntl(self.multi.socket, fcntl.F_GETFD) | fcntl.FD_CLOEXEC
|
||||||
# reset blocking status
|
fcntl.fcntl(self.multi.socket, fcntl.F_SETFD, flags)
|
||||||
self.multi.socket.setblocking(0)
|
# reset blocking status
|
||||||
|
self.multi.socket.setblocking(0)
|
||||||
|
|
||||||
signal.signal(signal.SIGINT, self.signal_handler)
|
signal.signal(signal.SIGINT, self.signal_handler)
|
||||||
signal.signal(signal.SIGTERM, signal.SIG_DFL)
|
signal.signal(signal.SIGTERM, signal.SIG_DFL)
|
||||||
signal.signal(signal.SIGCHLD, signal.SIG_DFL)
|
signal.signal(signal.SIGCHLD, signal.SIG_DFL)
|
||||||
@@ -812,7 +817,8 @@ class WorkerCron(Worker):
|
|||||||
def start(self):
|
def start(self):
|
||||||
os.nice(10) # mommy always told me to be nice with others...
|
os.nice(10) # mommy always told me to be nice with others...
|
||||||
Worker.start(self)
|
Worker.start(self)
|
||||||
self.multi.socket.close()
|
if self.multi.socket:
|
||||||
|
self.multi.socket.close()
|
||||||
|
|
||||||
#----------------------------------------------------------
|
#----------------------------------------------------------
|
||||||
# start/stop public api
|
# start/stop public api
|
||||||
|
|||||||
Reference in New Issue
Block a user