Git Product home page Git Product logo

python-gflags's Introduction

python-gflags's People

Contributors

craigcitro avatar gpshead avatar jd-boyd avatar mrovner avatar nathdobson avatar nya3jp avatar vrusinov avatar yilei avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-gflags's Issues

Need a way to ignore all undefined flags

Currently, when gflags module sees an unrecognized flag, it throws an exception 
and give up processing.  Even if we catch the exception and ignore it, we end 
up with a half baked flag registry.

The option "undefok" does part of the work, but it works only on specifically 
whitelisted flags.  It would be great to have an option to have it ignore ALL 
unrecognized flags.

Original issue reported on code.google.com by [email protected] on 22 Mar 2012 at 5:29

python-gflags-2.0 test failures; py2.7, pypy

What steps will reproduce the problem?
1. Run testsuite under py2.7, pypy
2.
3.

What is the expected output? What do you see instead?
Pass.
Failures

What version of the product are you using? On what operating system?
python-gflags-2.0

Please provide any additional information below.

>>> Source compiled.
 * pypy1_9: running distutils-r1_run_phase python_test OR pypy2_0
.......F...F.
======================================================================
FAIL: testFlagHelpInXML_SpaceSeparatedList 
(__main__.WriteFlagHelpInXMLFormatTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "gflags_helpxml_test.py", line 253, in testFlagHelpInXML_SpaceSeparatedList
    self._CheckFlagHelpInXML('dirs', 'tool', expected_output)
  File "gflags_helpxml_test.py", line 102, in _CheckFlagHelpInXML
    self.assertMultiLineEqual(sio.getvalue(), expected_output)
  File "/mnt/gen2/TmpDir/portage/dev-python/python-gflags-2.0/work/python-gflags-2.0/tests/gflags_googletest.py", line 104, in assertMultiLineEqual
    unittest.TestCase.assertMultiLineEqual(self, expected, actual)
AssertionError: " <flag>\n   <file>tool</file>\n   <name>dirs</name>\n   
<meaning>Directories to [truncated]... != " <flag>\n   <file>tool</file>\n   
<name>dirs</name>\n   <meaning>Directories to [truncated]...
   <flag>
     <file>tool</file>
     <name>dirs</name>
     <meaning>Directories to search.</meaning>
     <default>src libs bin</default>
     <current>['src', 'libs', 'bin']</current>
     <type>whitespace separated list of strings</type>
-    <list_separator>' '</list_separator>
     <list_separator>'\t'</list_separator>
     <list_separator>'\n'</list_separator>
-    <list_separator>'\r'</list_separator>
     <list_separator>'\x0b'</list_separator>
     <list_separator>'\x0c'</list_separator>
+    <list_separator>'\r'</list_separator>
+    <list_separator>' '</list_separator>
   </flag>


======================================================================
FAIL: testWriteHelpInXMLFormat (__main__.WriteHelpInXMLFormatTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "gflags_helpxml_test.py", line 527, in testWriteHelpInXMLFormat
    self.assertMultiLineEqual(actual_output, expected_output)
  File "/mnt/gen2/TmpDir/portage/dev-python/python-gflags-2.0/work/python-gflags-2.0/tests/gflags_googletest.py", line 104, in assertMultiLineEqual
    unittest.TestCase.assertMultiLineEqual(self, expected, actual)
AssertionError: '<?xml version="1.0"?>\n<AllFlags>\n  
<program>gflags_helpxml_test.py</program>\ [truncated]... != '<?xml 
version="1.0"?>\n<AllFlags>\n  <program>gflags_helpxml_test.py</program>\ 
[truncated]...
Diff is 5042 characters long. Set self.maxDiff to None to see it.

----------------------------------------------------------------------
Ran 13 tests in 0.041s

FAILED (failures=2)

dev-python/python-gflags $ PYTHON_TARGETS="python2_7" ebuild  
python-gflags-2.0.ebuild clean test

yields

>>> Source compiled.
 * python2_7: running distutils-r1_run_phase python_test
.............
----------------------------------------------------------------------
Ran 13 tests in 0.015s

OK
.........E......EEEWarning: Hit circular flagfile dependency: 
/mnt/gen2/TmpDir/portage/dev-python/python-gflags-2.0/temp/python2.7/gflags_unit
testuxxTfV/UnitTestFile3.tst
EEEEE..E.EEF.........
======================================================================

Log attached for py2.7

Original issue reported on code.google.com by [email protected] on 4 Jul 2013 at 2:26

Attachments:

setup.py installs Python scripts as 'data' rather than 'scripts'

The setup.py script lists the Python script as a 'data file', alike:

      data_files=[("bin", ["gflags2man.py"])],

while it should be a 'script' instead:

      scripts=["gflags2man.py"],

Installing it a script will make sure that distutils correctly update the 
Python shebang and make the script executable.

I'm attaching a patch fixing setup.py.

Original issue reported on code.google.com by [email protected] on 16 Dec 2012 at 3:41

Attachments:

Failing to execute pytest or other binary commands with gflags

Hi there,

I'm using gflags for accepting command line arguments in one of the script recently added in application. There are unit testcases in the application that I execute using pytest library. Unit test execution was working fine till the time GFLAGS library was not sys path. After adding gflags, the command line arguments provided to pytest or py.test or any other command in interpreted/interrupted by the GFlags and it ultimately throw back the following error.

python_gflags-2.0-py2.6.egg/gflags.py:1319: in call
raise UnrecognizedFlagError(opt, value)
E UnrecognizedFlagError: Unknown command line flag 'cov-config'

---------- coverage: platform linux2, python 2.7.5-final-0 -----------

Command I'm executing is mentioned below. Is there any way to disable/force gflags to ignore such commands?
py.test --cov-config .coveragerc --cov-report html --cov=.

pip install python-gflags fails: "file gflags.py (for module gflags) not found"

Downloading/unpacking python-gflags
  Running setup.py (path:/tmp/pip_build_root/python-gflags/setup.py) egg_info for package python-gflags

    file gflags.py (for module gflags) not found
Installing collected packages: python-gflags
  Running setup.py install for python-gflags
    file gflags.py (for module gflags) not found
    file gflags.py (for module gflags) not found

    file gflags.py (for module gflags) not found
    warning: install_lib: 'build/lib.linux-x86_64-2.7' does not exist -- no Python modules to install

    file gflags.py (for module gflags) not found
Successfully installed python-gflags
Cleaning up...

There doesn't seem to be any option in setup.py to install to a directory other than /usr/local

What steps will reproduce the problem?
1. Issue 'python ./setup.py install as a non-root user
2. It fails and displays a message suggesting the use of --prefix or --
install-dir.
3. However, using --prefix or --install-dir goes unrecognized by setup.py.

What is the expected output? What do you see instead?

I expect an option that permits me to install python gflags at a different 
location than the default.

What version of the product are you using? On what operating system?

1.3. Ubuntu 9.10.

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 11 Jan 2010 at 6:10

DuplicateFlagError when module with gflags definition is reimported

A DuplicateFlagError is thrown when:
1) Module A imports the gflags module and defines gflags.
2) Module A imports B
3) Module B imports A

Example:

File main.py:
---------------------------------
#!/usr/bin/python2.6

import sys
import gflags
import dep   # error

FLAGS = gflags.FLAGS
gflags.DEFINE_boolean("example", True, "example_flag")

if __name__ == "__main__":
  FLAGS(sys.argv)
  print FLAGS.example

---------------------------------


File dep.py:
---------------------------------
#!/usr/bin/python2.6

import main
---------------------------------


Error output:
---------------------------------
Traceback (most recent call last):
  File "example\main.py", line 10, in <module>
    gflags.DEFINE_boolean("example", True, "example_flag")
  File "C:\gflags\python\gflags.py", line 2378, in DEFINE_boolean
    DEFINE_flag(BooleanFlag(name, default, help, **args), flag_values)
  File "C:\gflags\python\gflags.py", line 2190, in DEFINE_flag
    fv[flag.name] = flag
  File "C:\gflags\python\gflags.py", line 1040, in __setitem__
    raise DuplicateFlagError(name, self)
gflags.DuplicateFlagError: The flag 'example' is defined twice. First from 
main, Second from example\main.py

Original issue reported on code.google.com by [email protected] on 26 Mar 2012 at 7:11

Provide a migration strategy from python-gflags to absl-py

https://pypi.python.org/pypi/absl-py/ (https://github.com/abseil/abseil-py) replaces this library. We need to document the migration strategy.

Also consider if there is even more we could do such as having python-gflags depend on absl-py or even push a version implemented on top of it? Though it'd be a lot better to not provide such a crutch and just reach out to anything with a python-gflags dep to have them update to absl-py directly.

broken link on main gflags page

What steps will reproduce the problem?
1. visit http://code.google.com/p/python-gflags/
2. find the line "Documentation is at the top of gflags.py."
3. click on the 'gflags.py' link

What is the expected output? What do you see instead?

take me to the source of gflags.py

What version of the product are you using? On what operating system?

n/a

Please provide any additional information below.

it should link to 
http://code.google.com/p/python-gflags/source/browse/trunk/gflags.py

Original issue reported on code.google.com by [email protected] on 2 May 2010 at 10:54

  • Merged into: #2

unicode not supported in help strings

What steps will reproduce the problem?
1. Define a flag with a non-ascii character in the help string.
2. Run ./your_app --help
3. *BOOM*

What is the expected output? What do you see instead?

I was hoping to see my string in the help output, instead ./app --help gave me 
this:
Traceback (most recent call last):
  File "foo.py", line 8, in <module>
    FLAGS(sys.argv)
  File "/home/soren/gflagstest/gflags.py", line 1188, in __call__
    flag.Parse(arg)
  File "/home/soren/gflagstest/gflags.py", line 2249, in Parse
    flags = str(FLAGS)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 158-160: 
ordinal not in range(128)

What version of the product are you using? On what operating system?
SVN trunk (r16), Ubuntu Natty (python 2.7.1


Please provide any additional information below.
I'm attaching a script to reproduce.

Original issue reported on code.google.com by [email protected] on 14 Mar 2011 at 10:21

Attachments:

gflags_unittest.py does not respect TMPDIR

The tests in gflags_unittest.py rely on a hardcoded path in /tmp. This raises 
sandbox violations when the build is performed in an isolated environment, and 
has a collision potential when running tests for multiple Python 
implementations in parallel.

The test should at least respect the TMPDIR environment variable. I'm attaching 
a patch which uses tempfile.mkdtemp() to obtain an unique temporary directory, 
respecting TMPDIR.

Original issue reported on code.google.com by [email protected] on 16 Dec 2012 at 4:06

Attachments:

Add the label 'Google' for consistency w/ other Google contributions

What steps will reproduce the problem?
1.
2.
3.

What is the expected output? What do you see instead?


What version of the product are you using? On what operating system?


Please provide any additional information below.


Original issue reported on code.google.com by david.spencerian on 18 Feb 2010 at 6:49

ERROR:root:Trying to access flag xxx before flags were parsed.

I am facing an issue when I want to use python gflags.
Here is how I am using it :

import gflags
FLAGS = gflags.FLAGS
gflags.DEFINE_integer('xxx', 3,'xxx')
if FLAGS.xxx == 3:
    print ok

I run the program with : python myProg.py

It seems that the program is working, but I always have this error message :

ERROR:root:Trying to access flag xxx before flags were parsed.
Traceback (most recent call last):
File "/home/toto/PythonEnv/local/lib/python2.7/site-packages/gflags/flagvalues.py", line 535, in getattr
raise exceptions.UnparsedFlagAccessError(error_message)
UnparsedFlagAccessError: Trying to access flag xxx before flags were parsed.

Do you know why ?

Should DEFINE_boolean() allow "None" as the default value?

Currently, we can define a boolean flag with default value to None:

 FLAGS = gflags.FLAGS
 gflags.DEFINE_boolean("the_flag", None, "The flag.")

I'm not sure if this is expected or should it be allowed, since python-gflags 
project tries to mimic the C++ version of gflags as close as possible.  This is 
troublesome because user may be unaware that a boolean flag can fail both of 
the following assertions:

 assertTrue(FLAGS.the_flag)  # AssertionError: None is not True
 assertFalse(FLAGS.the_flag)  # AssertionError: None is not False

Original issue reported on code.google.com by [email protected] on 4 Apr 2012 at 8:04

python-gflags builds SONAMEs which conflict with google-gflags

What steps will reproduce the problem?
1. Build the software
2.
3.

What is the expected output? What do you see instead?
If any shared libraries are built, they don't have the same SONAMEs as the 
already existing ones.

What version of the product are you using? On what operating system?
python-gflags-1.3, Solaris 8

Please provide any additional information below.

library files for google-gflags:

maciej@build8s [build8s]:~/src/opencsw/pkg/python-gflags/trunk > grep lib 
../../google-gflags/trunk/work/solaris8-sparc/build-
global/CSWgflags.prototype-sparc 
s none /opt/csw/lib/libgflags.so=libgflags.so.0.0.0
s none /opt/csw/lib/libgflags.so.0=libgflags.so.0.0.0
f none /opt/csw/lib/libgflags.so.0.0.0 0755 root bin
s none /opt/csw/lib/libgflags_nothreads.so=libgflags_nothreads.so.0.0.0
s none /opt/csw/lib/libgflags_nothreads.so.0=libgflags_nothreads.so.0.0.0
f none /opt/csw/lib/libgflags_nothreads.so.0.0.0 0755 root bin
s none /opt/csw/lib/sparcv9/libgflags.so=libgflags.so.0.0.0
s none /opt/csw/lib/sparcv9/libgflags.so.0=libgflags.so.0.0.0
f none /opt/csw/lib/sparcv9/libgflags.so.0.0.0 0755 root bin
s none 
/opt/csw/lib/sparcv9/libgflags_nothreads.so=libgflags_nothreads.so.0.0.0
s none 
/opt/csw/lib/sparcv9/libgflags_nothreads.so.0=libgflags_nothreads.so.0.0.0
f none /opt/csw/lib/sparcv9/libgflags_nothreads.so.0.0.0 0755 root bin

The same for python-gflags:

maciej@build8s [build8s]:~/src/opencsw/pkg/python-gflags/trunk > grep lib 
work/solaris8-sparc/build-global/CSWpython-gflags.prototype-sparc 
f none /opt/csw/lib/libgflags.so.0.0.0 0755 root bin
s none /opt/csw/lib/libgflags.so.0=libgflags.so.0.0.0
s none /opt/csw/lib/libgflags.so=libgflags.so.0.0.0
f none /opt/csw/lib/libgflags_nothreads.so.0.0.0 0755 root bin
s none /opt/csw/lib/libgflags_nothreads.so.0=libgflags_nothreads.so.0.0.0
s none /opt/csw/lib/libgflags_nothreads.so=libgflags_nothreads.so.0.0.0

Both projects create files with the same names:

google-gflags:
/opt/csw/lib/libgflags.so.0

python-gflags:
/opt/csw/lib/libgflags.so.0

It's not possible to build packages with google-gflags and python-gflags, 
because of conflicting files.  Perhaps C++ code should be stripped off 
python-gflags and a dependency should be added?

Original issue reported on code.google.com by [email protected] on 20 Feb 2010 at 2:45

Documentation and examples

It would be nice if this project published documentation and examples.

As a secondary issue the readme refers to a "gflags.py" file which does not exist. Presumably this should just be "flags.py".

Please clarify github.com/gflags/python-gflags

I found what looks like an out-of-date version of this repository at github.com/gflags/python-gflags. That repository is linked to by https://code.google.com/archive/p/python-gflags/, so I thought it was the official repository for quite a while. If that repository is owned by the same people as this one, please consider either removing it from github (ideally) or adding a note to the README file there that this repository is kept up-to-date.

If possible, it would also be great to update https://code.google.com/archive/p/python-gflags/, but less important.

Test for permission errors fails as root

When running unit tests as root (i.e. as part of a install process that runs as 
root) one test fails because root can still read files with 0 for permissions. 
Attached is a pretty trivial way to skip the test that is compatible with any 
version of python. A fancier way in >= 2.7 would be to call self.skipTest().

Original issue reported on code.google.com by [email protected] on 28 Jun 2013 at 6:37

Attachments:

Dependency management

It looks like there was a switch to distutils from setuptools. Though there is an attempt to manage dependencies with it (i.e. six), but that won't work. Only setuptools supports that behavior. Also would the keyword needs to be changed.

xref: 21f8668#commitcomment-21106396

Error running "acoustics_1d_example1.ipynb"

I tried running the acoustics 1D example using the Jupyter notebook but I had an error:

IndexError: list index out of range.

Can someone please help me solve this code error?I'm a beginner in clawpack and python language. Below is the code that gives the error and the error message received.

import clawpack.visclaw.JSAnimation.JSAnimation_frametools as J anim = J.make_anim(plotdir, figno=1, figsize=(6,4)) anim

IndexError Traceback (most recent call last)
in ()
1 import clawpack.visclaw.JSAnimation.JSAnimation_frametools as J
----> 2 anim = J.make_anim(plotdir, figno=1, figsize=(6,4))
3 anim

~/anaconda3/lib/python3.6/site-packages/clawpack/visclaw/JSAnimation/JSAnimation_frametools.py in make_anim(plotdir, fname_base, figno, figsize)
80 ax = fig.add_axes([0, 0, 1, 1])
81 ax.axis('off') # so there's not a second set of axes
---> 82 im = plt.imshow(image.imread(filenames[0]))
83
84 def init():

IndexError: list index out of range

Getting this installed on pipi and other ecosystem benefits

Is there any interest in getting this so it can be installed via 
pip/easy_install? Possibly adding support for tox?

Actually this is a patch for the latter (it has a problem with pypy though - 
sort order seems different?):

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..0ac728b
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+*.pyc
+.tox/
+python_gflags.egg-info/
diff --git a/tox.ini b/tox.ini
new file mode 100644
index 0000000..b51f490
--- /dev/null
+++ b/tox.ini
@@ -0,0 +1,9 @@
+[tox]
+envlist=py26,py27,pypy
+
+[testenv]
+commands=
+  python tests/gflags_googletest.py
+  python tests/gflags_helpxml_test.py
+  python tests/gflags_unittest.py
+  python tests/gflags_validators_test.py

Original issue reported on code.google.com by [email protected] on 12 Nov 2012 at 8:19

python <name of program> -- does not give error.

What steps will reproduce the problem?

In your example code :
EXAMPLE USAGE:


  FLAGS = gflags.FLAGS

  # Flag names are globally defined!  So in general, we need to be
  # careful to pick names that are unlikely to be used by other libraries.
  # If there is a conflict, we'll get an error at import time.
  gflags.DEFINE_string('name', 'Mr. President', 'your name')
  gflags.DEFINE_integer('age', None, 'your age in years', lower_bound=0)
  gflags.DEFINE_boolean('debug', False, 'produces debugging output')
  gflags.DEFINE_enum('gender', 'male', ['male', 'female'], 'your gender')

  def main(argv):
    try:
      argv = FLAGS(argv)  # parse flags
    except gflags.FlagsError, e:
      print '%s\\nUsage: %s ARGS\\n%s' % (e, sys.argv[0], FLAGS)
      sys.exit(1)
    if FLAGS.debug: print 'non-flag arguments:', argv
    print 'Happy Birthday', FLAGS.name
    if FLAGS.age is not None:
      print 'You are a %d year old %s' % (FLAGS.age, FLAGS.gender)

  if __name__ == '__main__':
    main(sys.argv)

-------------------------------------------------------
[admin@gaudalvi-centos6 client]$ python temp.py --
Happy Birthday Mr. President

This should be error.

What is the expected output? What do you see instead?
Happy Birthday Mr. President

What version of the product are you using? On what operating system?
Cent OS 6.6
Python 2.6.6

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 18 Feb 2015 at 10:51

Python 3.4 import error

I have installed gflags on python3.4 env.
And after i attempt import gflags it raise "No module named 'cStringIO' "

It should by changed from io import StringIO

Possibly update look like below?

from


gflags/argument_parser.py 
import cStringIO
import csv
import string

to


gflags/argument_parser.py
try: 
     from io import StringIO as cStringIO
except:
     import cStringIO#original code here
import csv
import string

broken link on front page to gflags.py

What steps will reproduce the problem?
1. Go to http://code.google.com/p/python-gflags/
2. Click on "gflags.py" here:
    Documentation is at the top of gflags.py.


3. you get a 40 4 at http://python-
gflags.googlecode.com/svn/trunk/python/gflags.py

What is the expected output? What do you see instead?


What version of the product are you using? On what operating system?


Please provide any additional information below.

You probably want http://code.google.com/p/python-
gflags/source/browse/trunk/gflags.py


Original issue reported on code.google.com by david.spencerian on 18 Feb 2010 at 6:38

Test suite doesn't pass

What steps will reproduce the problem?
1. Extract tarball.
2. Run unit tests (python gflags_unittest.py)

What is the expected output? What do you see instead?
The test suite should pass.

Instead, I get this:
Traceback (most recent call last):
  File "gflags_unittest.py", line 51, in <module>
    import test_module_baz as module_baz
ImportError: No module named test_module_baz

What version of the product are you using? On what operating system?
1.5.1 on Ubuntu 11.04

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 14 Jun 2011 at 12:03

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.