summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Updated from global requirements1.0.00.3.0OpenStack Proposal Bot2014-09-112-4/+10
| | | | Change-Id: Iedf0c7f3592011c26343481fcb2a5354d6bd9c15
* Merge "Work toward Python 3.4 support and testing"Jenkins2014-09-081-1/+1
|\
| * Work toward Python 3.4 support and testingJeremy Stanley2014-09-031-1/+1
| | | | | | | | Change-Id: I8cc372429540dd5bbe65d57ac7e8764823c268a9
* | Check for namedtuple_as_object support before using it0.2.0Matt Riedemann2014-09-031-1/+7
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit ad248f6658d572f3f4721f804325db754e9c931d introduced the usage of the namedtuple_as_object kwarg if using simplejson. However, that kwarg isn't available until simplejson 2.2.0 which is a problem for anyone running a RHEL/CentOS 6 distribution. Normally this would not be a big deal since we can bump minimum required versions but in this case simplejson is an optional runtime dependency so most projects don't list it in their requirements.txt files. So if you are running with simplejson < 2.2.0 (you might not even know it) and upgrade, things are going to get sad very quick. Rather than assume people will be at the right level or figure it out, let's be smarter and just check if the kwarg is available in the version of simplejson we're using. If we don't have a new enough version of simplejson then fallback to using json despite the performance issues on python 2.6. This can be removed in Kilo when python 2.6 support is dropped so this should be short-term workaround that saves some headaches once Juno is released. Closes-Bug: #1361230 Change-Id: Iadc2d28a1a0b125a34ed08344673c6b4a8a758e9
* Updated from global requirements0.1.0OpenStack Proposal Bot2014-08-261-1/+1
| | | | Change-Id: I453c26122ce55dbf49d5a34491091b4789825d59
* Clean up docs before first releaseDoug Hellmann2014-08-255-27/+25
| | | | | | Add basic API documentation and release notes. Change-Id: I18fc06d23d8e46baf153a150e6af896c7bb67f04
* Updated from global requirementsOpenStack Proposal Bot2014-08-243-7/+15
| | | | Change-Id: Ief3ff160a479dfb1d0602038ba7c14580ec08d21
* Added JSONEncoder and JSONDecoderIhar Hrachyshka2014-08-221-0/+4
| | | | | | | | Users may be interested in subclassing them, and they should not intermix different implementations, so let's provide them with implementation agnostic classes. Change-Id: I63ecd5dbbf78089d9e5c43ca5895c748eb23f070
* Add some basic docstring(s)Davanum Srinivas2014-08-211-2/+32
| | | | Change-Id: I8a7b188b89552b9e0c84558774ebd1913236dc98
* Fix docs build to run properlyDavanum Srinivas2014-08-216-5/+19
| | | | Change-Id: I7f684bc48c5ce913a5799f78c80bda459cf35f65
* Use oslo libraries - i18n and utilsDavanum Srinivas2014-08-2111-1091/+13
| | | | | | | | | | Remove the files synced from oslo-incubator and adjust the openstack-common.conf. Note that _message.Message extends six.text_type so we don't need the extra condition check in jsonutils.py. Tests have been updated to use the fixture in i18n 0.2.0 to avoid directly referring to private modules. Change-Id: I971df3a154317a5dff93c83143092c98023b84c9
* Specify namedtuple_as_object=False when using simplejsonYAMAMOTO Takashi2014-08-142-2/+23
| | | | | | | This makes namedtuple serialization consistent with non simplejson case. Closes-Bug: #1356173 Change-Id: I9dd879914c7cb226c71e856914536318b416e488
* Get unit tests passingBen Nemec2014-07-1419-1911/+1194
|
* exported from oslo-incubator by graduate.shBen Nemec2014-07-1429-0/+2430
|
* Added missing jsonutils.dump() functionIhar Hrachyshka2014-07-072-0/+13
| | | | | | | | | The function is missing from the module, meaning that some module consumers can't use jsonutils as a complete replacement for stdlib json module. Change-Id: Ia678d251a3984c959ae6c9d7ad70d33b197da4ff Closes-Bug: 1338571
* pep8: fixed multiple violationsIhar Hrachyshka2014-06-201-3/+3
| | | | | | | | | | | | | | | | | Fixed violations: * E128 continuation line under-indented for visual indent * E251 unexpected spaces around keyword / parameter equals * E265 block comment should start with '# ' * E713 test for membership should be 'not in' * F402 import shadowed by loop variable * H305 imports not grouped correctly * H307 like imports should be grouped together' * H402 one line docstring needs punctuation' * H703 Multiple positional placeholders Also enabled H803 check that didn't have any violations. Change-Id: I957ab273ddc61b02763d6b60b21d11ed4e73d472
* Add kwargs to jsonutils.load(s) functionsNataliia Uvarova2014-05-292-4/+9
| | | | | | | | Now jsonutils.load(s) doesn't allow to pass additional params to underlying json.load(s) (such as 'parse_int' or 'cls'). This patch adds kwargs to jsonutils.load(s) that are passed to json.load(s). Change-Id: I9b032e6047b207ad3af14dadd90f207e3a9ca0e5
* Enforce unicode json output for jsonutils.load[s]()Ihar Hrachyshka2014-04-302-9/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | simplejson module applies some optimizations on ASCII-only unicode strings which result in non-unicode json output. See details at [1] and [2]. To make sure we always return consistent json output no matter which json implementation is used, we should explicitly convert the input for json.load[s]() to unicode. If user wants to pass a file object of non UTF-8 encoding to json.load[s](), she must also specify this encoding as an argument. To support this scenario too, we've added 'encoding' argument to jsonutils.load[s]() implementation. Made all present JSON tests to run on both supported json library implementations. Added explicit dependency for simplejson to be able to test different implementations in unit tests. Distributors still running Python 2.6 are recommended but not required to install simplejson. Related-Bug: 1314129 [1]: https://code.djangoproject.com/ticket/11742 [2]: https://code.google.com/p/simplejson/issues/detail?id=40 Change-Id: Ic815ca3df94c33edec9104172048b2cd94b92e3f
* jsonutils.load() accepts file pointer, not stringIhar Hrachyshka2014-04-301-2/+2
| | | | | | | | | Renamed jsonutils.load() argument name to more appropriate one. This name is also used in stdlib json documentation [1]. 1: https://docs.python.org/2/library/json.html#json.load Change-Id: Ia0cfce0e023ce29d3aad80a71039343643820bb4
* On Python <= 2.6, use simplejson if availableIhar Hrachyshka2014-04-291-1/+11
| | | | | | | | | | | | | Until Python 2.7, stdlib json module was not boosted with a C extension, meaning bad performance. Try to use simplejson module if available. RHEL 6.5 is one of the platforms that still ship Python 2.6. The original idea of the patch belongs to Miguel Angel Ajo Pelayo @ mangelajo@redhat.com Change-Id: Ib3dc0b713ed90396919feba018772243b3b9c90f Closes-Bug: 1314129
* Use oslotest instead of common test moduleVictor Sergeyev2014-04-151-3/+3
| | | | | | | | Module openstack.common.test is obsolete, so we should use oslotest library instead of it. Modified tests and common database code, new requirement added. Change-Id: I853e548f11a4c3785eaf75124510a6d789536634
* Python3: enable test_jsonutils.pyCyril Roelandt2014-03-131-2/+11
| | | | | Change-Id: I22f5d92c4c0034162b6fc27b785bd034d4d25f86 Blueprint: make-python3-compatible
* Use six.moves.xmlrpc_client instead of xmlrpclibCyril Roelandt2014-02-272-15/+2
| | | | | | Implement jaypipes' note about this, to improve Python 2/3 compatibility. Change-Id: I89d27045142dd46ed8d91871ce3681ea9032cfe3
* Translation Message improvementsLuis A. Garcia2013-10-311-2/+2
| | | | | | | | | | | | | | | | | | | | | The improvements to the current Message implementation include: * Implementing a new method translate() to explicitely perform the translation of a Message object, instead of relying on setting the 'locale' property. * All of the codebase assumes _() is a unicode object, so make the Message unicode, that will always behave as unicode, except for the fact that it has the extra ability to translate() on demand. * Remove the internal representation of the translated Message (i.e. the data property) and rely on parent implementations. * Enhancement to the corresponding TestTranslation class to enable fake translations for multiple locales. With this patch the REST API translation in the other projects will work with very minimal or no impact after re-enabling the 'lazy' _(). Partially implements: bp i18n-messages Change-Id: I2dbddf422e79fd4474dede1e7c7ed229c89dc30c
* Python3 support for xmlrpclibJay Pipes2013-12-051-3/+7
| | | | | | | | | | | | | | | | Python3 actually does include xmlrpc(lib). It's just called xmlrpc.client. The class and function signatures are the same as the old Python2.x xmlrpclib module. Adds a note that six.moves should be used once six 1.4.2 is released. See http://bit.ly/1bqrVzu. References: Python 2 xmprpllib doc: http://docs.python.org/2/library/xmlrpclib.html Python 3 xmlrpc.client doc: http://docs.python.org/3/library/xmlrpc.client.html Change-Id: I478b56f22d02350a21093a887d9f6fcb84958724
* Use six.iteritems to make dict work on Python2/3Chang Bo Guo2013-11-281-1/+1
| | | | | | | | | six.iteritems returns an iterator over dictionary‘s items. This replaces dictionary.iteritems() on Python 2 and dictionary.items() on Python 3. See http://pythonhosted.org/six/#six.iteritems Implements: blueprint make-python3-compatible Change-Id: I90be87979ebc7eccd11d66cd1eef16d9b2eb9fda
* Remove vim headerJoe Gordon2013-10-112-4/+0
| | | | | | | | No need to set tabstop 189 times, this can be set in your vimrc file instead. Also if set incorrectly gate (pep8 check) will catch your mistakes. Change-Id: Ic6f0c0ef94e8194a5c121598305d1ec3c74e4843
* Ensure that Message objects will be sent via RPC in unicode formatGary Kotton2013-09-232-0/+18
| | | | | | | Fixes bug 1229204 Change-Id: Ia915f3175bee370d747e362cd9d35d8536c1b7b2 Co-authored-by: He Jie Xu <xuhj@linux.vnet.ibm.com>
* jsonutils: make types py3 compatibleJulien Danjou2013-08-221-2/+2
| | | | | | | In Python 3, there's no long nor NoneType. Let's replace by equivalent values. Change-Id: Id1aa7af26b0f5d929337cc373c6a4f802bba2cec
* jsonutils: do not require xmlrpclibJulien Danjou2013-08-222-3/+12
| | | | | | | xmlrpclib isn't shipped anymore in Python 3, so let's support it optionally. Change-Id: Ic94f238a5f92f28ae1b6154fb56f00c4c9fa3283
* Make dependency on netaddr optionalDirk Mueller2013-08-041-2/+3
| | | | | | | | https://review.openstack.org/#/c/38023/ pointed out that the dependency on netaddr is unnecessary and can be avoided. Use try_import to avoid a hard dependency on netaddr. Change-Id: I8b246f20f9001379fcb5ca3a84aabee3847cb945
* Bump hacking to 0.7.0Zhongyue Luo2013-08-161-23/+23
| | | | | | Fixes H202, H602 errors Change-Id: Ic3045f15116d1d7a28b63bc94a0a341b9304ffdd
* Replace using tests.utils with openstack.common.testAlexander Gorodnev2013-08-091-3/+3
| | | | | | | | | It is the first step to replace using tests.utils with openstack.common.test. All these tests don't use mock objects, stubs, config files and use only BaseTestCase class. Change-Id: I511816b5c9e6c5c34ebff199296ee4fc8b84c672 bp: common-unit-tests
* Enable H302 hacking checkAnn Kamyshnikova2013-06-251-2/+2
| | | | | | This change requires hacking >0.5.5 Change-Id: Ic36fa0502548335d433f3fbe663854523dd04397
* Add netaddr.IPAddress support to to_primitive()Dan Smith2013-06-252-0/+9
| | | | | | | | | | This enlightens jsonutils.to_primitive() about how to serialize netaddr.IPAddress objects. Since these types are serializable in their native form with just string coercion, just do that here. Fixes bug 1195097 Change-Id: I358b0731e4d3774e5b36aefb5384fdfb75fd31b6
* python3: python3 binary/text data compatbilityChuck Short2013-05-241-2/+3
| | | | | | | | | | | | | Python3 enforces the distinction between byte strings far more rigorously than Python 2 does; binary data cannot be automatically coerced to or from text data. Use six to provide a fake file object for textual data. It provides an alias for StringIO.StringIO in python2 and io.StringIO in python3 Change-Id: I65897bb0cca2cbeb5819a769b98645c9eb066401 Signed-off-by: Chuck Short <chuck.short@canonical.com>
* Convert unicode for python3 portabilityChuck Short2013-05-011-3/+5
| | | | | | | | | | | | | From http://docs.python.org/3.1/whatsnew/3.0.html: "Python 3.0 uses the concepts of text and (binary) data instead of Unicode strings and 8-bit strings." Use six.text_type to Type for representing (Unicode) textual data. This is unicode() in Python 2 and str in Python 3. Change-Id: I3da268a714a34a8e626a2590f01b86e414dc3411 Signed-off-by: Chuck Short <chuck.short@canonical.com>
* Optimise to_primitive common casesStanislaw Pitucha2013-04-081-16/+42
| | | | | | | | | | | | | | to_primitive included many checks that were executed before any usual types have been checked. It's safe to reorder / duplicate the most common ones. Especially built-in types can be checked before other more complicated scenarios. This is important since to_primitive gets called over a million times in usual test run and many more times in a live environment. This change strips around 4% of nova testing time on my machine and the function itself is ~5x faster on average according to the profiler. Change-Id: I71e0c06bbcc31793a1cdcebb36d4e3d8c5876f73
* Update to use flake8.Monty Taylor2013-03-191-1/+1
| | | | | | | flake8 is pluggable and handles pep8 and pyflakes, as well as configuration through tox.ini. It also removes the need for flakes.py. Change-Id: If5f7d8ad348b4fb8119fa4ec7b5e9d17bdc72a39
* Fix Copyright Headers - Rename LLC to FoundationDavanum Srinivas2013-03-111-1/+1
| | | | | | One code change, rest are in headers Change-Id: I73f59681358629e1ad74e49d3d3ca13fcb5c2eb1
* Don't LOG.error on max_depth (by default).Dan Prince2013-03-021-6/+0
| | | | | | | | | | | | Reverts part of a94b9b4 which added an extra LOG.error statement when max_depth is hit. This is causing spurious errors to get logged in some of our projects which have adopted this changed. Related to: https://bugs.launchpad.net/nova/+bug/1140133 Change-Id: Ie7939e41797da000dd8b269f905f351df0b7116d
* to_primitive imposes what seems to be an arbitary data structurePhil Day2013-02-112-3/+36
| | | | | | | | | | | | | | | | | | | depth of 3, but there is at least on case in Nova (Security group Rules) which requires a depth beyond this. https://bugs.launchpad.net/nova/+bug/1118608 Specifically security_group_rule_get_by_security_group returns a set of rules which have the structure: rule -> grantee_group -> Instance -> Instance_type Rather than just bumping the depth limit, which might break some other user of to_primitive we make it a specific parameter that defaults to the current value but can be over-ridden when required and log a warning when the depth is exceeded Change-Id: I1eaebd484e20cb2eae09a693289709973de9943c
* Allow to_primitive to ignore datetimesJoe Gordon2013-02-052-21/+17
| | | | | | | | | | | | In preparation for having nova.db.api not return any sqlalchemy objects. nova.db.api will return only primitives, except for datetime.datetime objects. Uses functools.partial to make code DRYING Partially implements bp db-api-cleanup Change-Id: I9980d8c4e20b05bbe734cf90ac209e4e7e89befb
* Replace direct use of testtools BaseTestCase.Monty Taylor2013-01-231-3/+3
| | | | | | | | | Using the BaseTestCase across the tests in the tree lets us put in log fixtures and consistently handle mox and stubout. Part of blueprint grizzly-testtools. Change-Id: Iba7eb2c63b0c514009b2c28e5930b27726a147b0
* Use testtools as test base class.Monty Taylor2013-01-221-3/+3
| | | | | | | | | | | | | On the path to testr migration, we need to replace the unittest base classes with testtools. Replace tearDown with addCleanup, addCleanup is more resilient than tearDown. The fixtures library has excellent support for managing and cleaning tempfiles. Use it. Replace skip_ with testtools.skipTest Part of blueprint grizzly-testtools. Change-Id: I45e11bbb1ff9b31f3278d3b016737dcb7850cd98
* Fixes import order errorsZhongyue Luo2013-01-181-1/+1
| | | | Change-Id: I3e35230dd2d96ab9f5a8c11b9ec1cd8d2d00e347
* Make project pyflakes clean.Monty Taylor2012-11-211-1/+1
| | | | | | | | | | | | | Added both a tox test-env for pyflakes and fixed the current pyflakes errors. This did actually fix a couple of bugs. The CI team has started using pyflakes on its projects and also has started using oslo for things, so ignoring pyflakes warnings on the oslo code was starting to get old. However, additionally, pyflakes is pretty solid, so we should maybe consider gating on it across the board. (% locals() is the biggest thing that we do that it doesn't like) Change-Id: Iac1ca62db301892b7863711162fcbc74807eb24f
* Add missing convert_instances arg.Russell Bryant2012-07-181-1/+3
| | | | | | | | When calling jsonutils.to_primitive() recursively, the convert_instances argument should be passed along. This change fixes one place where it was not. Change-Id: I536e1ca05bb4e613fba71298797879587e8b4b00
* Track to_primitive() depth after iteritems().Russell Bryant2012-07-182-1/+19
| | | | | | | | | | | | | | | | | | Change jsonutils.to_primitive() to increase the recursion depth counter when calling to_primitive() on the result of iteritems() from the current element. Previously, the only time the counter was increased was when converting the __dict__ from an object. The iteritems() case risks cycles, as well. I hit a problem with this when trying to call to_primitive on an instance of nova.db.sqlalchemy.models.Instance. An Instance includes a reference to InstanceInfoCache, which has a reference back to the Instance. Without this change, to_primitive() would raise an exception for an Instance due to excessive recursion. Related to nova blueprint no-db-messaging. Change-Id: Ifb878368d97e92ab6c361a4dd5f5ab2e68fc16e2
* Update iteritems test case to actually test iteritems.Russell Bryant2012-07-181-11/+4
| | | | | | | | | | | | | This patch updates the jsonutils.to_primitive() test case for when an object has an iteritems() method. The previous implementation was mostly a copy of another test and didn't actually test calling iteritems() at all. Now it does. This is used by NovaBase in nova.db.sqlalchemy.models. Related to nova blueprint no-db-messaging. Change-Id: Ie1d71b859219392ab35b82dd3c7932b30e759c89