Exemple #1
0
def pip_install(site=None, *packages):
    # TODO: support upgrading packages with pip install --upgrade packagename
    # Check for pip first
    with hide('everything'), settings(warn_only=True):
        result = run('dpkg -s python-pip')
    if not result.succeeded:
        apt_get_install('python-pip')
    if site and len(packages) == 0:
        packages = tuple(site.get('pip_packages',
                                  [])) + get_requirements_packages()
    pip = get_pip_installer(site)
    # Install each listed package
    for package in packages:
        name, version = split_package(package)
        if site is None:
            if package in _pip_install_set:
                continue
            _pip_install_set.add(package)
        if package.startswith('git:') or package.startswith('git+'):
            apt_get_install('git')
        with hide('everything'), settings(warn_only=True):
            result = run('%s show "%s"' % (pip, name))
        # Check the output of pip show, it doesn't return non-zero on not finding the package, just no output
        if not len(result.strip()):
            from hooks import hook
            with hook('pip install %s' % name):
                # sudo with -H for setting the home directory for root so pip has proper permissions to cache
                run('sudo -H %s install "%s"' % (pip, package))
        else:
            print '%s already installed.' % name
        class Derive(Base):
            value3 = 0

            @hook('bar')
            def func3(self):
                self.value3 = 3

            func2 = hook('bar')(Base.func2)
Exemple #3
0
def apt_get_install(*packages):
    for package in packages:
        if package in _apt_get_install_set:
            continue
        _apt_get_install_set.add(package)
        # Check for the package
        with hide('everything'), settings(warn_only=True):
            result = run('dpkg -s %s' % package)
        if not result.succeeded:
            # TODO: separate the version from the package
            from hooks import hook
            with hook('apt-get install %s' % package):
                sudo('apt-get install %s -y' % package)
        else:
            print '%s already installed.' % package
Exemple #4
0
def apt_get_install(*packages):
    for package in packages:
        if package in _apt_get_install_set:
            continue
        _apt_get_install_set.add(package)
        # Check for the package
        with hide('everything'), settings(warn_only=True):
            result = run('dpkg -s %s' % package)
        if not result.succeeded:
            # TODO: separate the version from the package
            from hooks import hook
            with hook('apt-get install %s' % package):
                sudo('apt-get install %s -y' % package)
        else:
            print '%s already installed.' % package
Exemple #5
0
def pip_install(site=None, *packages):
    # TODO: support upgrading packages with pip install --upgrade packagename
    # Check for pip first
    with hide('everything'), settings(warn_only=True):
        result = run('dpkg -s python-pip')
    if not result.succeeded:
        apt_get_install('python-pip')
    if site and len(packages) == 0:
        packages = tuple(site.get('pip_packages', [])) + get_requirements_packages()
    pip = get_pip_installer(site)
    # Install each listed package
    for package in packages:
        name, version = split_package(package)
        if site is None:
            if package in _pip_install_set:
                continue
            _pip_install_set.add(package)
        if package.startswith('git:') or package.startswith('git+'):
            apt_get_install('git')
        from hooks import hook
        with hook('pip install %s' % name):
            # sudo with -H for setting the home directory for root so pip has proper permissions to cache
            run('sudo -H %s install "%s"' % (pip, package))
Exemple #6
0
 def register_hook(self, hook_name, hook_fn):
     hook(self, hook_name)(hook_fn)
Exemple #7
0
 def hook(self, hook_name):
     return hook(self, hook_name)
Exemple #8
0
def hook_tag(context, name, *args, **kwargs):
    return format_html_join(
        sep="\n",
        format_string="{}",
        args_generator=((response, )
                        for response in hook(name, context, *args, **kwargs)))
Exemple #9
0
from django.conf.urls import include
from django.contrib import admin
from django.urls import path, re_path
from django.views.generic import TemplateView
from django.conf import settings
from django.conf.urls.static import static

from hooks import hook
from main.views import index_customer
from django.contrib.auth import views as auth_views

urlpatterns = [
    path('', index_customer, name="index"),
    path('accounts/', include('django.contrib.auth.urls')),
    path('comprobantes/', include('comprobante.urls')),
    path('empresa/', include('empresa.urls')),
    path(r'ayuda/', include('help.urls')),
    path(r'afip/', include('afip.urls')),
    # path(r'^ckeditor/', include('ckeditor.urls')),
    path('admin/', admin.site.urls),
    path(
        'robots.txt',
        TemplateView.as_view(template_name='robots/client.txt',
                             content_type='text/plain'))
]

urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

urlpatterns += hook('pirra.urlpatterns')
Exemple #10
0
 def __call__(self, request):
     hook("hooks.before_request", request)
     response = self.get_response(request)
     hook("hooks.after_response", request, response)
     return response
Exemple #11
0
 def process_view(request, view_func, view_args, view_kwargs):
     for response in hook("hooks.process_view", request, view_func,
                          view_args, view_kwargs):
         if response:
             return response
     return
Exemple #12
0
            if self._lastday != time.localtime()[2]:
                self._lastday = time.localtime()[2]
                msg += time.ctime() + '\n'
            if self.timestamp:
                msg += time.strftime('[%H:%M:%S] ')
            msg += self.buffer[:index+1]
            self.buffer = self.buffer[index+1:]
            if isinstance(msg, type(u'')):
                msg = msg.encode('utf-8', 'backslashreplace')
            self.f.write(msg)
            self.f.flush()
            self.lock.release()
            index = self.buffer.find('\n')

    def writeline(self, msg):
        self.write(msg.rstrip('\n') + '\n')

    def close(self):
        self.write('\n')
        self.f.close()

if __name__ == "__main__":
    err = LogWriter('/home/santiclause/ircbot/error.log', True)
    sys.stderr = err
    #out = LogWriter('/home/santiclause/ircbot/output.log', True)
    main = IRC('irc.rizon.net', 6667, 'Bot-sama', 'eden', 'Eden Radio', err=err)
    import hooks
    hooks.hook(main)
    main.connect()
    main.start()