Return an async job from a dict output by Async.to_dict.
517621
def from_dict(cls, async):
        """"""
        async_options = decode_async_options(async)

        target, args, kwargs = async_options.pop('job')

        return cls(target, args, kwargs, **async_options)
140725
def fetch_task_output(self):
        
        # 
        if os.path.isfile(os.path.join(self.tmp_dir, "job.out")):
            with open(os.path.join(self.tmp_dir, "job.out"), "r") as f_out:
                outputs = f_out.readlines()
        else:
            outputs = ''
        return outputs
229771
def iterate(it):
    """"""
    if is_async_iterable(it):
        return from_async_iterable.raw(it)
    if isinstance(it, Iterable):
        return from_iterable.raw(it)
    raise TypeError(
        f"{type(it).__name__!r} object is not (async) iterable")
62102
def from_dict(cls, message):
        """"""

        message_options = message.copy()

        # JSON don't like datetimes.
        eta = message_options.get('task_args', {}).get('eta')
        if eta:
            from datetime import datetime

            message_options['task_args']['eta'] = datetime.fromtimestamp(eta)

        return Message(**message_options)
378171
def as_json(self, ensure_ascii=False):
        """"""
        return json.dumps(self.as_dict, ensure_ascii=ensure_ascii)
869289
def encode_async_options(async):
    """"""
    options = copy.deepcopy(async._options)

    options['_type'] = reference_to_path(async.__class__)

    # JSON don't like datetimes.
    eta = options.get('task_args', {}).get('eta')
    if eta:
        options['task_args']['eta'] = time.mktime(eta.timetuple())

    callbacks = async._options.get('callbacks')
    if callbacks:
        options['callbacks'] = encode_callbacks(callbacks)

    if '_context_checker' in options:
        _checker = options.pop('_context_checker')
        options['__context_checker'] = reference_to_path(_checker)

    if '_process_results' in options:
        _processor = options.pop('_process_results')
        options['__process_results'] = reference_to_path(_processor)

    return options
1146720
def dumps(self, sort_keys: bool = True, **kwargs) -> str:
        """"""
        return json.dumps(self.to_json(), sort_keys=sort_keys, **kwargs)
353653
def serialize_job(job):
    """"""
    d = dict(
        id=job.get_id(),
        uri=url_for('jobs.get_job', job_id=job.get_id(), _external=True),
        status=job.get_status(),
        result=job.result
    )
    return d
694775
def dump_dict_to_file(dictionary, filepath):
    """"""
    create_dirs(
        os.path.dirname(filepath)
    )

    with open(filepath, 'a') as outfile:
        json.dump(dictionary, outfile)
        outfile.write('\n')
1190395
def async_get(self, handle):
        '''  '''
        assert handle in self._thread_pool, 'Invalid async call handle'
        result = self._thread_pool[handle].result_queue.get()
        del self._thread_pool[handle]
        return result
118456
def python(source):
    
    """
    obj = type('', (object,), {})()
    _exec(source, obj.__dict__, obj.__dict__)
    return obj
908255
def make_dict(cls, table):
        """"""
        ret_dict = {}
        for row in table:
            job_details = cls.create_from_row(row)
        ret_dict[job_details.dbkey] = job_details
        return ret_dict
909067
def _convert_to_dict(stdout):
    

    lines = stdout.split("\n")
    lines = list(filter(None, lines))
    info_dict, j = _get_dict(lines, 0, 0, 0)
    return info_dict
1126744
def as_dict(self, ordered=False):
        """"""
        items = zip(self.keys(), self.values())

        return OrderedDict(items) if ordered else dict(items)
1274028
def async_from_options(options):
    """"""
    _type = options.pop('_type', 'furious.async.Async')

    _type = path_to_reference(_type)

    return _type.from_dict(options)
160892
def parse_query_output(cls, out):
        
        query_data = {}

        for line in out.strip().split("\n"):
            parts = line.split()
            if len(parts) < 6:
                continue

            job_id = parts[0]
            status_flag = parts[2]

            # map the status
            status = cls.map_status(status_flag)

            # save the result
            query_data[job_id] = cls.job_status_dict(job_id=job_id, status=status)

        return query_data
1028719
def local_async(self, *args, **kwargs):
        '''
        
        '''
        local = salt.client.get_local_client(mopts=self.opts)
        ret = local.run_job(*args, **kwargs)
        return ret