def upload_asciinema(filename):
    '''a wrapper around generation of an asciinema.api.Api to call the 
       upload command given an already existing asciinema file. 

       Parameters
       ==========
       filename: the asciinema file to upload, can be generated with 
                 function record_asciinema in record.py

    '''
    if os.path.exists(filename):

        import asciinema.config as aconfig
        from asciinema.api import Api

        # Load the API class

        cfg = aconfig.load()
        api = Api(cfg.api_url, os.environ.get("USER"), cfg.install_id)

        # Perform the upload, return the url

        uploader = UploadCommand(api, filename)
    
        try:
            url, warn = uploader.api.upload_asciicast(filename)
            if warn:
                uploader.print_warning(warn)

            # Extract just the url, if provided (always is https)
            if url:
                match = re.search('https://.+', url)
                if match: 
                    url = match.group() 
            return url

        except:
            bot.error('Problem with upload, skipping')

    else:
        bot.warning('Cannot find %s, skipping submission.' %filename)
def upload_asciinema ( filename ) : if os . path . exists ( filename ) : import asciinema . config as aconfig from asciinema . api import Api cfg = aconfig . load ( ) api = Api ( cfg . api_url , os . environ . get ( "USER" ) , cfg . install_id ) uploader = UploadCommand ( api , filename ) try : url , warn = uploader . api . upload_asciicast ( filename ) if warn : uploader . print_warning ( warn ) if url : match = re . search ( 'https://.+' , url ) if match : url = match . group ( ) return url except : bot . error ( 'Problem with upload, skipping' ) else : bot . warning ( 'Cannot find %s, skipping submission.' % filename )
a wrapper around generation of an asciinema.api.Api to call the 
       upload command given an already existing asciinema file. 

       Parameters
       ==========
       filename: the asciinema file to upload, can be generated with 
                 function record_asciinema in record.py