How do I use environment variables in Supervisord's [supervisord] config section? - supervisord

I use environment variables in Supervisord's program section, and they work just fine:
[program:some_prog]
command=%(ENV_env_var_name)s/...
I can't figure out though how to do the same in the [supervisord] section.
I tried using the same syntax with and without the ENV_ prefix, but getting the following error:
Traceback (most recent call last):
File "/usr/local/bin/supervisord", line 9, in <module>
load_entry_point('supervisor==3.0a12', 'console_scripts', 'supervisord')()
File "/usr/local/lib/python2.7/dist-packages/supervisor-3.0a12-py2.7.egg/supervisor/supervisord.py", line 356, in main
options.realize(args, doc=__doc__)
File "/usr/local/lib/python2.7/dist-packages/supervisor-3.0a12-py2.7.egg/supervisor/options.py", line 419, in realize
Options.realize(self, *arg, **kw)
File "/usr/local/lib/python2.7/dist-packages/supervisor-3.0a12-py2.7.egg/supervisor/options.py", line 284, in realize
self.process_config_file()
File "/usr/local/lib/python2.7/dist-packages/supervisor-3.0a12-py2.7.egg/supervisor/options.py", line 478, in process_config_file
Options.process_config_file(self, do_usage=do_usage)
File "/usr/local/lib/python2.7/dist-packages/supervisor-3.0a12-py2.7.egg/supervisor/options.py", line 292, in process_config_file
self.read_config(self.configfile)
File "/usr/local/lib/python2.7/dist-packages/supervisor-3.0a12-py2.7.egg/supervisor/options.py", line 527, in read_config
section.directory = existing_directory(directory)
File "/usr/local/lib/python2.7/dist-packages/supervisor-3.0a12-py2.7.egg/supervisor/datatypes.py", line 336, in existing_directory
nv = v % {'here':here}
KeyError: 'var_name'
Is there a way to achieve that?

Supervisor only supports expansions with environment variables in a limited number of locations, each of which is documented in the configuration documentation.
Unfortunately, the [supervisord] directory option is not one of those; it only supports the %(here) variable, nothing else.
You could file a feature request for this in the supervisord issue tracker if this an important issue for you.
In my projects, we generally use zc.buildout to make deployment and development environment setup predictable and repeatable, and generate the supervisor configuration from a template. There is a specialized buildout recipe to make this task easier.

Related

gsutil ConfigParser.ParsingError: File contains parsing errors

I'm working on a fastlane lane using pink-room's fastlane firebase test lab plugin which needs a gcloud service account to connect to firebase and upload files to a bucket.
The service account is needed because the script runs in a docker container which must not be worked by humans.
Gcloud command seem to work, because the test are launched as intended, but the gsutil command which is use to upload raw results is failing.
When this service account is loaded, gsutil commands stop working because they throw a ConfigParser.ParsingError "File contains parsing errors".
Here is what I get when trying to execute gsutil version -l in order to gather more informations:
Exit status of command 'gsutil version -l' was 1 instead of 0.
Traceback (most recent call last):
File "/usr/local/gcloud/google-cloud-sdk/platform/gsutil/gsutil", line 22, in <module>
gsutil.RunMain()
File "/usr/local/gcloud/google-cloud-sdk/platform/gsutil/gsutil.py", line 116, in RunMain
import gslib.__main__
File "/usr/local/gcloud/google-cloud-sdk/platform/gsutil/gslib/__main__.py", line 39, in <module>
import boto
File "/usr/local/gcloud/google-cloud-sdk/platform/gsutil/third_party/boto/boto/__init__.py", line 53, in <module>
config = Config()
File "/usr/local/gcloud/google-cloud-sdk/platform/gsutil/third_party/boto/boto/pyami/config.py", line 63, in __init__
self.read(BotoConfigLocations)
File "/usr/lib/python2.7/ConfigParser.py", line 305, in read
self._read(fp, filename)
File "/usr/lib/python2.7/ConfigParser.py", line 546, in _read
raise e
ConfigParser.ParsingError: File contains parsing errors: /builds/project-0/gcloud
/legacy_credentials/<service account mail>/.boto
[line 3]: '/legacy_credentials/<service account mail>/adc.json'
Here is my .boto file :
[Credentials]
gs_service_key_file = /builds/project-0/gcloud/legacy_credentials/<service account mail>/adc.json
Do someone knows where this error comes from, and how I can fix it ?
You say your boto file only has 2 lines, but I don't think that's the case, based on your error message :) I'm guessing either there's whitespace in there that you're not seeing (some unicode character that might not render correctly in your editor, perhaps?), or you didn't copy/paste the contents exactly as they appear in your file.
After finding a similar issue in this blog post, I noticed that the error you're seeing will print out the entire content of each problematic line that it found. It says it's printing line 3 (that shouldn't be possible if the boto file has only 2 lines), but doesn't show the gs_service_key_file = text. I'm guessing there's some sort of line break between gs_service_key_file = and /build/project-0/... in your boto file.

AWS SAM Local RuntimeError in Eclipse

I am trying to run a basic lambda function (using article blueprint in AWS serverless project creator in Eclipse). When I try to run the project as AWS SAM Local, I get an error:
Traceback (most recent call last):
File "/Users/bliu4/.local/bin/sam", line 11, in <module>
sys.exit(cli())
File "/Users/bliu4/anaconda3/lib/python3.6/site-packages/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/Users/bliu4/anaconda3/lib/python3.6/site-packages/click/core.py", line 676, in main
_verify_python3_env()
File "/Users/bliu4/anaconda3/lib/python3.6/site-packages/click/_unicodefun.py", line 118, in _verify_python3_env
'for mitigation steps.' + extra)
RuntimeError: Click will abort further execution because Python 3 was configured to use ASCII as encoding for the environment. Consult http://click.pocoo.org/python3/for mitigation steps.
Has anyone else run into this issue? Any idea how to change the python version sam is calling? Thanks.

Issue with whois and subprocess (Python 3.4; 64-bit Windows)

So I'm just trying to get the suggested query (domain = whois.query("google.com")) working. But whenever I run it, I get the following traceback:
File "file.py", line x, in weight_sources
domain = whois.query("google.com")
File "C:\Users\User Name\Anaconda3\lib\site-packages\whois\__init__.py", line 50, in query
pd = do_parse(do_query(d, force, cache_file, slow_down, ignore_returncode), tld)
File "C:\Users\User Name\Anaconda3\lib\site-packages\whois\_1_query.py", line 44, in do_query
_do_whois_query(dl, ignore_returncode),
File "C:\Users\User Name\Anaconda3\lib\site-packages\whois\_1_query.py", line 58, in _do_whois_query
p = subprocess.Popen(['whois', '.'.join(dl)], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
File "C:\Users\User Name\Anaconda3\lib\subprocess.py", line 856, in __init__
restore_signals, start_new_session)
File "C:\Users\User Name\Anaconda3\lib\subprocess.py", line 1111, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
I've seen some other questions/answers point to line 1111 in subprocess, but I think the issue might be in whois as I have used subprocess extensively without error on my device. Since the non-existent file seems to be related to the whois package, I don't think this question is related to this one, although the two could be related?
Essentially, is there any work around for this error or if I need to edit the whois package code, how would I go about that? I'm not exactly sure I even fully understand what "file" is missing...
The missing file is the whois executable, which is opened here:
subprocess.Popen(['whois', '.'.join(dl)]
The package description says whois is a wrapper for the Linux whois command. That means you must be running on Linux and have whois installed, but you are running Windows.
So I think you're out of luck with this package, maybe another one (such as python-whois) supports Windows.

sublime text 2 phpcs plugin python error

I am using Sublime Text 2 with some plugins. I can't seem to work with the Phpcs plugin, because after saving the file, it gives me an ugly error:
Writing file /Applications/XAMPP/xamppfiles/htdocs/myProject/application/libraries/Authentication.php with encoding UTF-8
Exception in thread Thread-15:
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/threading.py", line 532, in __bootstrap_inner
self.run()
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/threading.py", line 484, in run
self.__target(*self.__args, **self.__kwargs)
File "./phpcs.py", line 398, in run
File "./phpcs.py", line 128, in get_errors
File "./phpcs.py", line 194, in execute
File "./phpcs.py", line 197, in parse_report
File "./phpcs.py", line 149, in shell_out
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 623, in __init__
errread, errwrite)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 1141, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
I have also tried to look into the respective files, but I don't know python at all so I don;t know what to do :-/
Could You please help ?
I ended up using SublimeLinter plugin that provides the showing-potential-errors feature that I wanted from the phpcs plugin.
The plugin is located in THIS GITHUB REPO.
Hope this helps anybody who is having a problem using the phpcs library.
#daniel: Thanks for help

Move a Pinax project

(Cross post from Pinax Users Google group -- I figured it would be useful to have this question on here as well.)
I'm a bit stuck. My projects work fine when I run them on the original machine I create them on, but I get an error when I move them to another machine. I'm trying to use hosted version control to manage a project between two computers, but it only works on the machine I create it on. I'm just trying to get the project base "zero" to run on both machines. Here's the console output I'm getting when I run manage.py runserver:
Traceback (most recent call last):
File "manage.py", line 27, in <module>
execute_from_command_line()
File "/home/loren/pinax-env/lib/python2.6/site-packages/django/core/management/__init__.py", line 352, in execute_from_command_line
utility.execute()
File "/home/loren/pinax-env/lib/python2.6/site-packages/django/core/management/__init__.py", line 306, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/loren/pinax-env/lib/python2.6/site-packages/django/core/management/base.py", line 192, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/loren/pinax-env/lib/python2.6/site-packages/django/core/management/base.py", line 210, in execute
translation.activate('en-us')
File "/home/loren/pinax-env/lib/python2.6/site-packages/django/utils/translation/__init__.py", line 73, in activate
return real_activate(language)
File "/home/loren/pinax-env/lib/python2.6/site-packages/django/utils/translation/__init__.py", line 43, in delayed_loader
return g['real_%s' % caller](*args, **kwargs)
File "/home/loren/pinax-env/lib/python2.6/site-packages/django/utils/translation/trans_real.py", line 209, in activate
_active[currentThread()] = translation(language)
File "/home/loren/pinax-env/lib/python2.6/site-packages/django/utils/translation/trans_real.py", line 198, in translation
default_translation = _fetch(settings.LANGUAGE_CODE)
File "/home/loren/pinax-env/lib/python2.6/site-packages/django/utils/translation/trans_real.py", line 181, in _fetch
app = getattr(__import__(appname[:p], {}, {}, [appname[p+1:]]), appname[p+1:])
AttributeError: 'module' object has no attribute 'messages'
I expect that this has something to do with my pythonpath, but I'm just too new to this to know where to look. I dug up this thread, but I couldn't find a solution in it:
Django failing to find apps
Help would be great!