当前位置: 首页>>代码示例>>Python>>正文


Python core.Core类代码示例

本文整理汇总了Python中core.Core的典型用法代码示例。如果您正苦于以下问题:Python Core类的具体用法?Python Core怎么用?Python Core使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Core类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: send_update_mails

def send_update_mails(ticket, ticket_update):
    """
    Sends email to all users who commented or created ticket
    """
    assigned_sent = check_assigned_to(ticket)

    recipients = set([])

    if not ticket.mailbox_hash:

        ticket.mailbox_hash = hashlib.sha224("ticket-%s"%ticket.id).hexdigest()
        ticket.save()

    if ticket.assigned_to:
        if ticket.assigned_to.email:
            recipients.add(ticket.assigned_to.email)

    if not assigned_sent and ticket.assigned_to:
        if ticket.assigned_to.email in recipients:
            recipients.remove(ticket.assigned_to.email)

    for recipient in ticket.get_recipients():
        if recipient.email:
            recipients.add(recipient.email)

    if Core.current_user().email:
        if Core.current_user().email in recipients:
            recipients.remove(Core.current_user().email)

    if ticket_update.public and ticket_update.comment:
        _send_to_clients(ticket, ticket_update)

    msg = _create_msg(ticket, ticket_update)
    send_mail(_("Ticket update"), msg, "support+"+ticket.mailbox_hash+"@focustime.no", recipients)
开发者ID:frecar,项目名称:focus,代码行数:34,代码来源:utils.py

示例2: is_authenticated

    def is_authenticated(self, request):
        #Check if already logged in, for use inside the application
        if Core.current_user() and Core.current_user().is_authenticated():
            return True

        #If not, then use basic auth
        else:
            auth_string = request.META.get('HTTP_AUTHORIZATION', None)

            if not auth_string:
                return False

            (authmeth, auth) = auth_string.split(" ", 1)

            if not authmeth.lower() == 'basic':
                return False

            auth = auth.strip().decode('base64')
            (username, password) = auth.split(':', 1)

            if Core.login(request, username, password):
                user = User.objects.get(username=username)
                return user.canLogin

        return False
开发者ID:frecar,项目名称:focus,代码行数:25,代码来源:authentication.py

示例3: products

def products(request, id):
    supplier = Core.current_user().get_permitted_objects("VIEW", Supplier).get(id=id)
    products = Core.current_user().get_permitted_objects("VIEW", Product).filter(supplier=supplier)

    return render(request, 'suppliers/products.html', {'title': _("Products"),
                                                       'supplier': supplier,
                                                       'products': products})
开发者ID:frecar,项目名称:focus,代码行数:7,代码来源:views.py

示例4: process_request

    def process_request (self, request):

        # Save the current thread with the current user
        Core.attach_user(request)
        request.user = Core.current_user()

        return None
开发者ID:frecar,项目名称:focus,代码行数:7,代码来源:middleware.py

示例5: Azure

class Azure(ShowBase):
    def __init__(self):
        """Program entry point."""
        # TODO(Nemesis#13): rewrite ShowBase to not use globals.

        # This basically sets up our rendering node-tree, some builtins and
        # the master loop (which iterates each frame).
        ShowBase.__init__(self)

        # Turn off Panda3D's standard camera handling.
        self.disableMouse()

        self.setBackgroundColor(0,0,0,1)

        # Start our Core Finite State Machine
        self.core = Core()
        if (options.scenario):
            # Scenario was specified at command line.
            self.core.demand("Loading", options.scenario)
        else:
            self.core.demand("Menu", "MainMenu")

        #base.bufferViewer.toggleEnable()

		# Start the master loop.
        self.run()
开发者ID:hubertgrzeskowiak,项目名称:Azure--Infinite-Skies,代码行数:26,代码来源:main.py

示例6: form

def form (request, id=False):
    if id:
        instance = Core.current_user().get_permitted_objects("VIEW", Group).get(id=id)
        msg = _("Successfully edited group")
    else:
        instance = Group()
        msg = _("Successfully added new group")

    #Save and set to active, require valid form
    if request.method == 'POST':
        form = GroupForm(request.POST, instance=instance)
        if form.is_valid():
            o = form.save(commit=False)
            o.company = Core.current_user().get_company()
            o.save()
            form.save_m2m()

            request.message_success(msg)
            return redirect(overview)

    else:
        form = GroupForm(instance=instance)

    return render(request, "admin/groups/form.html",
                  {'title': _("Group"), 'group': instance, 'form': form})
开发者ID:frecar,项目名称:focus,代码行数:25,代码来源:group.py

示例7: handle

    def handle(self, *args, **kwargs):
        randomCompanyIdentifier = str(int(random.random() * 99999))

        company, user = createNewCustomer(
            "Ledere",
            "Bjarte Hatlenes",
            "superadmin" + randomCompanyIdentifier,
            "superadmin" + randomCompanyIdentifier,
            "Ansatte",
            "Focus Security AS" + randomCompanyIdentifier,
        )

        self.company = company
        self.user = user

        Core.set_test_user(user)
        password = generate_new_password_for_user(user)
        print "Company: %s " % company
        print "Current user is: %s " % Core.current_user()
        print "Current user is: %s " % Core.current_user().username
        print "Current users password: %s " % password

        self.customers = []
        self.projects = []

        self.seed_customers()
        self.seed_contacts()
        self.seed_projects()
        self.seed_orders()
        self.seed_offers()
        self.seed_tickets()
        self.seed_suppliers()
        self.seed_products()
开发者ID:frecar,项目名称:focus,代码行数:33,代码来源:seed.py

示例8: __init__

class Omr:
    '''
    This module parses the options from comand line and starts the process
    '''
    def __init__(self,options):
        '''
        Constructor
        @param options : program options
        '''
        self.core=None
        self.appfilepath=options.appfilepath
        self.datafilepath=options.datafilepath
        self.inputfolder=options.inputfolder
        self.threshold=options.threshold
        self.zbar=options.zbar
    
    def scan(self):
        '''
        Starts the processing. Supported image formats: all supported by OpenCV and PIL
        '''
        if self.inputfolder!=None and self.appfilepath!=None and self.datafilepath!=None:
            self.core=Core(glob.glob(self.inputfolder),self.appfilepath,self.datafilepath,self.threshold,self.zbar)
            self.core.run()
        else:
            print "usage: python omr.py -i regex -o output -a config -t threshold [-z]"
开发者ID:romualdoandre,项目名称:myomr,代码行数:25,代码来源:omr.py

示例9: filter_current_company

    def filter_current_company(self):

        #Check if no current_user
        if not Core.current_user():
            return None
        
        return super(PersistentManager, self).get_query_set().filter(deleted=False,
                                                                     company=Core.current_user().get_company())
开发者ID:frecar,项目名称:focus,代码行数:8,代码来源:managers.py

示例10: on_request

    def on_request(self, text, author):
        text = re.sub(self.regexp, '', text)
        text = re.sub(r'\s+$', '', text)

        lang = get_language(text, key=u'startword')

        if lang is not None:
            core = Core(lang)
            self.send_message(core.send_message(), author)
开发者ID:Swizz,项目名称:UnnamedGame,代码行数:9,代码来源:crawler.py

示例11: start

def start(daemon=True):
    if running_process.is_running():
        messages.abort(messages.WAS_RUNNING)

    core = Core()

    if daemon:
        daemonize()

    core.start()
开发者ID:iddl,项目名称:git-events,代码行数:10,代码来源:gitEvents.py

示例12: WinterApp

class WinterApp(object):
    """
        Main non-gui application class
    """
    __apiclass__ = WinterAPI
    __pmclass__ = WinterPM

    def getMethod(self, key, module='main'):
        if not key.startswith('_'):
            try:
                if module == 'core':
                    return getattr(self.core, key)
                elif module == 'main':
                    return getattr(self, key)
                else:
                    return getattr(WinterPlugin.objects.get(name=module), key)
            except Exception as e:
                pass
        return False

    def __getitem__(self, key):
        return self.getMethod('main', key)

    def loadConfigs(self):
        """
            Load configuration from file
        """
        self.config = WinterConfig(open(self.api.CWD + 'config/main.cfg'))
        self.p_config = WinterConfig(open(self.api.CWD + 'config/plugins.cfg'))
        self.schema = WinterConfig(open(self.api.CWD + 'config/schema.cfg'))

    def onSubsChange(self, key, value):
        print('%s changed to %s' % (key, value))

    def __init__(self):
        self.api = self.__class__.__apiclass__()

        global API
        API = self.__class__.__apiclass__
        self.loadConfigs()
        self.api.config = self.config
        self.api.ex = self.getMethod

        self.beforeCore()
        from core import Core

        self.core = Core()
        self.core.app = self
        self.core._afterInit()
        if self.config.options.plugins:
            WinterPlugin()
            self.pm = self.__class__.__pmclass__(self.p_config)

    def beforeCore(self):
        pass
开发者ID:averrin,项目名称:Darknessers,代码行数:55,代码来源:base.py

示例13: __init__

    def __init__(self, position, buttonName):
        # Inicia os objetos
        pygame.sprite.Sprite.__init__(self)
        core = Core()

        # Insere as imagens
        self.image, self.rect = core.loadImage(buttonName)

        # Define a posicao do botao
        self.rect.centerx = position[0]
        self.rect.centery = position[1]
开发者ID:gabrielkras,项目名称:Jogo_Python-As_Aventura_de_Bee,代码行数:11,代码来源:honey.py

示例14: save

    def save(self, *args, **kwargs):
        self.date = datetime.now()

        if 'user' in kwargs:
            self.creator = kwargs['user']
        else:
            self.creator = Core.current_user()

        if Core.current_user() and Core.current_user().get_company():
            self.company = Core.current_user().get_company()
            
        super(Log, self).save()
开发者ID:frecar,项目名称:focus,代码行数:12,代码来源:models.py

示例15: update

    def update(self, request, id=None):

        if id:
            trackers = [Core.current_user().get_permitted_objects("EDIT", TimeTracker).get(id=id)]
        else:
            trackers = Core.current_user().get_permitted_objects("EDIT", TimeTracker).all()
        for tracker in trackers:
            try:
                self._do_update(request, tracker)
            except ValueError as e:
                return {'error': str(e)}

        return {'success': True}
开发者ID:frecar,项目名称:focus,代码行数:13,代码来源:handlers.py


注:本文中的core.Core类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。