Exemplo n.º 1
0
    def handle(self,*args, **options):

        template = 'tools/template-registry.md'
        outfile = os.path.basename(template).replace('template-', "%s-" %REGISTRY_URI)
        now = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
        try:
            admin = ADMINS[0][0]
        except:
            admin = "sregistry-robot"
            bot.warning('No admin in settings, will use %s' %admin)
            pass

        # Generate a robot number
        number = choice(list(range(1,15571)))
        context = {"REGISTRY_URI":REGISTRY_URI,
                   "REGISTRY_NAME":REGISTRY_NAME,
                   "DOMAIN_NAME": DOMAIN_NAME,
                   "AUTHOR": admin,
                   "NUMBER": number,
                   "DATETIME_NOW": now}

        content = render_to_string(template, context)

        # Write to file
        with open(outfile,'w') as filey:
            filey.writelines(content)

        bot.newline()
        bot.info("Registry template written to %s!" %outfile)
        bot.newline()
        bot.info("Your robot is at https://vsoch.github.io/robots/assets/img/robots/robot%s.png" %number)
        bot.info("1. Fork and clone https://www.github.com/singularityhub/sregistry")
        bot.info("2. Add %s to the registries folder" %outfile)
        bot.info("3. Download your robot (or add custom institution image) under assets/img/[custom/robots]")
        bot.info("4. Submit a PR to validate your registry.")
Exemplo n.º 2
0
def expire_share(sid):
    '''expire a share based on its id, meaning deleting it so that
       it can no longer be used.

       Parameters
       ==========
       sid: the share id to expire
    '''
    from shub.apps.main.models import Share
    try:
        share = Share.objects.get(id=sid)
        share.delete()
    except Share.DoesNotExist:
        bot.warning("Share %s expired." % sid)