/
usr
/
libexec
/
kcare
/
python
/
kcarectl
/
Upload File
HOME
� �;jc @ s d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l m Z d d l m Z m Z m Z m Z m Z m Z d d l m Z e r� d d l m Z m Z m Z m Z d d l m Z n d � Z d e f d � � YZ d e f d � � YZ d S( i����N( t NamedTemporaryFile( t autht configt http_utilst ipv6_supportt log_utilst utils( t run_command( t Anyt Dictt Listt Optional( t Selfc C sP t | � } x4 d D], } | d k r5 d j | | � S| d :} q Wd j | � S( sB Render a byte count as a short human-readable string for the logs.t Bt KiBt MiBt GiBg �@s {0:.1f} {1}s {0:.1f} TiB( R R R R ( t floatt format( t num_bytest sizet unit( ( s2 /usr/libexec/kcare/python/kcarectl/delivery_kit.pyt format_size s t DataPackagec B s� e Z d Z d Z d Z d � Z e d � � Z e d � � Z d � Z d d e d � Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z e j d e j � d � � Z d � Z d � Z RS( s� Generic archive package for the patch server uploads pipeline. Based on DataPackage from eportal (delivery_kit.py). Subclasses supply the manifest `data_type`, the `upload_uri` to PUT the archive to and the `max_size` payload limit. t c C s d | _ g | _ d | _ d S( Ni ( t Nonet _tart _errors_buffert _total_payload_size( t self( ( s2 /usr/libexec/kcare/python/kcarectl/delivery_kit.pyt __init__- s c C s t � d S( N( t NotImplementedError( R ( ( s2 /usr/libexec/kcare/python/kcarectl/delivery_kit.pyt max_size3 s c C s | j � } t | j � S( N( t _ensure_tar_createdt strt name( R t tar( ( s2 /usr/libexec/kcare/python/kcarectl/delivery_kit.pyt archive_path8 s c C s� d } d } y. t t j | � d t d t �\ } } } Wn t k r[ } t | � } n X| r~ | j d j | | � � n | d k r� | j | d t j | d d ��n d S( Nt catch_stdoutt catch_stderrs! failed to dump stdout of {0}: {1}t data_bytest encodings utf-8( R R t shlext splitt Truet ExceptionR"