← Back to team overview

c2c-oerpscenario team mailing list archive

[Bug 666475] [NEW] [trunk] hr and photo.png

 

Public bug reported:

The hr addon reads a file named "photo.png" from "addons_path"
configuration setting. But this setting can have multiple paths,
separated by a comma. In this case, the function "_get_photo" crashes
the server.

/addons/hr/hr.py

Line 186:

- return open(os.path.join(
-     tools.config['addons_path'], 'hr/image', 'photo.png'),
-         'rb') .read().encode('base64')
+ paths = tools.config['addons_path'].split(',')
+ for path in paths:
+     filename = os.path.join(path, 'hr/image', 'photo.png')
+     if os.path.isfile(filename):
+         return open(filename, 'rb').read().encode('base64')
+ return None

NOTE: I have a problem with spaces in the editor

** Affects: openobject-addons
     Importance: Undecided
         Status: New


** Tags: hr

** Description changed:

  The hr addon reads a file named "photo.png" from "addons_path"
  configuration setting. But this setting can have multiple paths,
  separated by a comma. In this case, the function "_get_photo" crashes
  the server.
  
- 
  /addons/hr/hr.py
  
  Line 186:
  
- -        return open(os.path.join(
- -            tools.config['addons_path'], 'hr/image', 'photo.png'),
- -                    'rb') .read().encode('base64')
- +        paths = tools.config['addons_path'].split(',')
- +        for path in paths:
- +            filename = os.path.join(path, 'hr/image', 'photo.png')
- +            if os.path.isfile(filename):
- +                return open(filename, 'rb').read().encode('base64')
- +        return None
+ -         return open(os.path.join(
+ -            tools.config['addons_path'], 'hr/image', 'photo.png'),
+ -                    'rb') .read().encode('base64')
+ +        paths = tools.config['addons_path'].split(',')
+ +        for path in paths:
+ +            filename = os.path.join(path, 'hr/image', 'photo.png')
+ +            if os.path.isfile(filename):
+ +                return open(filename, 'rb').read().encode('base64')
+ +        return None

** Description changed:

  The hr addon reads a file named "photo.png" from "addons_path"
  configuration setting. But this setting can have multiple paths,
  separated by a comma. In this case, the function "_get_photo" crashes
  the server.
  
  /addons/hr/hr.py
  
  Line 186:
  
- -         return open(os.path.join(
- -            tools.config['addons_path'], 'hr/image', 'photo.png'),
- -                    'rb') .read().encode('base64')
- +        paths = tools.config['addons_path'].split(',')
- +        for path in paths:
- +            filename = os.path.join(path, 'hr/image', 'photo.png')
- +            if os.path.isfile(filename):
- +                return open(filename, 'rb').read().encode('base64')
- +        return None
+ - return open(os.path.join(
+ -     tools.config['addons_path'], 'hr/image', 'photo.png'),
+ -         'rb') .read().encode('base64')
+ + paths = tools.config['addons_path'].split(',')
+ + for path in paths:
+ +     filename = os.path.join(path, 'hr/image', 'photo.png')
+ +     if os.path.isfile(filename):
+ +         return open(filename, 'rb').read().encode('base64')
+ + return None
+ 
+ NOTE: I have a problem with spaces in the editor

** Tags added: hr

-- 
[trunk] hr and photo.png
https://bugs.launchpad.net/bugs/666475
You received this bug notification because you are a member of C2C
OERPScenario, which is subscribed to the OpenERP Project Group.

Status in OpenObject Addons Modules: New

Bug description:
The hr addon reads a file named "photo.png" from "addons_path" configuration setting. But this setting can have multiple paths, separated by a comma. In this case, the function "_get_photo" crashes the server.

/addons/hr/hr.py

Line 186:

- return open(os.path.join(
-     tools.config['addons_path'], 'hr/image', 'photo.png'),
-         'rb') .read().encode('base64')
+ paths = tools.config['addons_path'].split(',')
+ for path in paths:
+     filename = os.path.join(path, 'hr/image', 'photo.png')
+     if os.path.isfile(filename):
+         return open(filename, 'rb').read().encode('base64')
+ return None

NOTE: I have a problem with spaces in the editor





Follow ups

References