<commit_before>from openerp.osv import fields, osv

from mako.template import Template
from mako.lookup import TemplateLookup
import os, inspect
import re
import subprocess
import unicodedata
import socket

class virtualhost_ssl(osv.osv):
     _name =  'virtualhost.ssl'
     
     _columns = {
                 'name': fields.char('Name', size=64, required=True),
                 'certificateserver': fields.many2one('certificate.ssl', 'Certificate Server', required=True),
                 'servername': fields.char('Server Name', size=64, required=True),
                 'serveralias': fields.char('Server Alias', size=64, required=True),
                 'ip': fields.char('IP', size=16, required=True),
                 'port': fields.char('Port', size=5, required=True),
                 'logpath': fields.char('Log Path', size=64, required=True),
                 'state': fields.selection([('draft','Draft'), ('active','Active'), ('disable','Disable')], 'State', readonly=True, help="The state.", select=True),
                 }
     
     def get_ip(self, cr, uid, context=None):
         return socket.gethostbyname(socket.gethostname())
     
     _defaults = {
                  'logpath': lambda self, cr, uid, context: self.pool.get('ir.config_parameter').get_param(cr, uid, "log_path", context),
                  'ip': get_ip,
                  'port': lambda self, cr, uid, context: self.pool.get('ir.config_parameter').get_param(cr, uid, "virtualhost_port", context)
     }
     _sql_constraints = [('item_name_unique','unique(name)', 'Item Name must be unique!')]
     
     def validateURL(self, cr, uid, ids, url):
         regex = re.compile(
            r'^(?:http|ftp)s?://' # http:// or https://
            r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|' #domain...
            r'localhost|' #localhost...
            r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip
            r'(?::\d+)?' # optional port
            r'(?:/?|[/?]\S+)$', re.IGNORECASE)
         
         if regex.match(url) != None:
            return True
         else:
            raise osv.except_osv('Invalid URL', 'Please enter a valid URL address')
     
     def validateIP(self, cr, uid, ids, ip):
         if re.match('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}', ip) != None:
            return True
         else:
            raise osv.except_osv('Invalid IP', 'Please enter a valid IP address')
          
     def get_virtualhost_path(self, cr, uid, context=None):
         currentPath = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
         serverDir = os.path.join(currentPath, os.pardir)<commit_msg>Solucionado problema con el path de virtualhost<commit_after>from openerp.osv import fields, osv

from mako.template import Template
from mako.lookup import TemplateLookup
import os, inspect
import re
import subprocess
import unicodedata
import socket

class virtualhost_ssl(osv.osv):
     _name =  'virtualhost.ssl'
     
     _columns = {
                 'name': fields.char('Name', size=64, required=True),
                 'certificateserver': fields.many2one('certificate.ssl', 'Certificate Server', required=True),
                 'servername': fields.char('Server Name', size=64, required=True),
                 'serveralias': fields.char('Server Alias', size=64, required=True),
                 'ip': fields.char('IP', size=16, required=True),
                 'port': fields.char('Port', size=5, required=True),
                 'logpath': fields.char('Log Path', size=64, required=True),
                 'state': fields.selection([('draft','Draft'), ('active','Active'), ('disable','Disable')], 'State', readonly=True, help="The state.", select=True),
                 }
     
     def get_ip(self, cr, uid, context=None):
         return socket.gethostbyname(socket.gethostname())
     
     _defaults = {
                  'logpath': lambda self, cr, uid, context: self.pool.get('ir.config_parameter').get_param(cr, uid, "log_path", context),
                  'ip': get_ip,
                  'port': lambda self, cr, uid, context: self.pool.get('ir.config_parameter').get_param(cr, uid, "virtualhost_port", context)
     }
     _sql_constraints = [('item_name_unique','unique(name)', 'Item Name must be unique!')]
     
     def validateURL(self, cr, uid, ids, url):
         regex = re.compile(
            r'^(?:http|ftp)s?://' # http:// or https://
            r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|' #domain...
            r'localhost|' #localhost...
            r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip
            r'(?::\d+)?' # optional port
            r'(?:/?|[/?]\S+)$', re.IGNORECASE)
         
         if regex.match(url) != None:
            return True
         else:
            raise osv.except_osv('Invalid URL', 'Please enter a valid URL address')
     
     def validateIP(self, cr, uid, ids, ip):
         if re.match('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}', ip) != None:
            return True
         else:
            raise osv.except_osv('Invalid IP', 'Please enter a valid IP address')
          
     def get_virtualhost_path(self, cr, uid, context=None):
         currentPath = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
         serverDir = os.path.join(currentPath, os.pardir)
         serverDir = os.path.join(serverDir, os.pardir)
{'fraction_non_alphanumeric': 0.18002942258183155, 'fraction_numerical': 0.015446855461566752, 'mean_word_length': 2.405760801502818, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2765199', 'n_tokens_mistral': 1769, 'n_tokens_neox': 1744, 'n_words': 364}