[Kimchi-devel] [PATCH V2] Debug report file can not be found when downloading

Sheldon shaohef at linux.vnet.ibm.com
Thu Feb 27 06:23:03 UTC 2014


Reviewed-by: ShaoHe Feng <shaohef at linux.vnet.ibm.com>

On 02/26/2014 05:03 PM, Shu Ming wrote:
> Patchset 8bc4dded9 re-organized the various path generation for Kimchi.
> Unfortunately, the root static dir was changed which caused the static
> dir for debugreport file broken. To the user, he can not download the
> debugreport file generated.
> ---
>   src/kimchi/mockmodel.py          |  5 ++++-
>   src/kimchi/model/debugreports.py |  5 ++++-
>   src/kimchi/server.py             | 12 ++++++++++--
>   3 files changed, 18 insertions(+), 4 deletions(-)
>
> diff --git a/src/kimchi/mockmodel.py b/src/kimchi/mockmodel.py
> index b23a024..7aaf54d 100644
> --- a/src/kimchi/mockmodel.py
> +++ b/src/kimchi/mockmodel.py
> @@ -305,7 +305,10 @@ class MockModel(object):
>           ctime = os.stat(file_target).st_ctime
>           ctime = time.strftime("%Y-%m-%d-%H:%M:%S", time.localtime(ctime))
>           file_target = os.path.split(file_target)[-1]
> -        file_target = os.path.join("/data/debugreports", file_target)
> +
> +        prefix = '/data/debugreports'
> +        file_target = os.path.join(prefix, file_target)
> +
>           return {'file': file_target,
>                   'ctime': ctime}
>
> diff --git a/src/kimchi/model/debugreports.py b/src/kimchi/model/debugreports.py
> index 7573a5b..64ed8e8 100644
> --- a/src/kimchi/model/debugreports.py
> +++ b/src/kimchi/model/debugreports.py
> @@ -164,7 +164,10 @@ class DebugReportModel(object):
>           ctime = os.stat(file_target).st_ctime
>           ctime = time.strftime("%Y-%m-%d-%H:%M:%S", time.localtime(ctime))
>           file_target = os.path.split(file_target)[-1]
> -        file_target = os.path.join("/data/debugreports", file_target)
> +
> +        prefix = '/data/debugreports'
> +        file_target = os.path.join(prefix, file_target)
> +
>           return {'file': file_target,
>                   'ctime': ctime}
>
> diff --git a/src/kimchi/server.py b/src/kimchi/server.py
> index ef8e701..401136f 100644
> --- a/src/kimchi/server.py
> +++ b/src/kimchi/server.py
> @@ -108,11 +108,10 @@ class Server(object):
>           },
>           '/data/debugreports': {
>               'tools.staticdir.on': True,
> -            'tools.staticdir.dir': 'data/debugreports',
>               'tools.nocache.on': False,
>               'tools.kimchiauth.on': True,
>               'tools.staticdir.content_types': {'xz': 'application/x-xz'}
> -        },
> +        },
>           '/config/ui/tabs.xml': {
>               'tools.staticfile.on': True,
>               'tools.staticfile.filename': 'config/ui/tabs.xml',
> @@ -129,7 +128,16 @@ class Server(object):
>           }
>       }
>
> +    def __update_debugreport_config(self):
> +        debug_dict =   self.configObj['/data/debugreports']
> +        if paths.installed:
> +            debug_path = os.path.join(paths.state_dir, 'debugreports')
> +            debug_dict.update({'tools.staticdir.dir': debug_path})
> +        else:
> +            debug_dict.update({'tools.staticdir.dir': 'data/debugreports'})
> +
>       def __init__(self, options):
> +        self.__update_debugreport_config()
>           make_dirs = [
>               os.path.dirname(os.path.abspath(options.access_log)),
>               os.path.dirname(os.path.abspath(options.error_log)),


-- 
Thanks and best regards!

Sheldon Feng(冯少合)<shaohef at linux.vnet.ibm.com>
IBM Linux Technology Center




More information about the Kimchi-devel mailing list