Please find the GitLab repo for the terraform scripts which we are using.
enter link description here
Run in terraform plan gives the below error in an all-in-one.YAML file for the elastic search.
Error: Error in function call
on kubernetes.tf line 49, in locals:
49: resource_list = yamldecode(file("${path. module}/all-in-one.yaml")).items
|----------------
| path.module is "."
Call to function `"yamldecode"` failed: on line 458, column 1: unexpected extra
content after value.
enter image description here
As is describe in the fine manual:
Only one YAML document is permitted. If multiple documents are present in the given string then this function will return an error.
and one can trivially reproduce your error message:
content = yamldecode("---\nhello: world\n---\ntoo: bad\n")
on main.tf line 14, in resource "local_file" "example":
14: content = yamldecode("---\nhello: world\n---\ntoo: bad\n")
Call to function "yamldecode" failed: on line 2, column 1: unexpected extra
content after value.
Related
I've been having a problem lately where I can't access the value of any variable through their name. It's not a connection problem since I can read the value from the read() function just fine. However whenever I use the read_by_name function there's always the same error pyads.pyads_ex.ADSError: ADSError: Unknown Error (857212673).
Because it's an unknown error I haven't been able to find documentation on it. I'm using a BC9120 as a PLC and TwinCat 2. Does anyone know what might be causing this?
Code:
if self.plc.is_open == False:
self.plc.open()
print(self.plc.read(pyads.INDEXGROUP_MEMORYBIT, 0*8 + 0, pyads.PLCTYPE_BOOL))
print(self.plc.read_by_name("Test.M0", pyads.PLCTYPE_BOOL))
Logs:
False
Traceback (most recent call last):
File "c:\Users\MAP9AV\Documents\Banca\Modelo Preditivo\Thread_Sup.py", line 50, in run
print(self.plc.read_by_name("Test.M0", pyads.PLCTYPE_BOOL))
File "C:\Users\MAP9AV\AppData\Local\Programs\Python\Python39\lib\site-packages\pyads\connection.py", line 540, in read_by_name
return adsSyncReadByNameEx(
File "C:\Users\MAP9AV\AppData\Local\Programs\Python\Python39\lib\site-packages\pyads\pyads_ex.py", line 1154, in adsSyncReadByNameEx
handle = adsGetHandle(port, address, data_name)
File "C:\Users\MAP9AV\AppData\Local\Programs\Python\Python39\lib\site-packages\pyads\pyads_ex.py", line 890, in adsGetHandle
handle = adsSyncReadWriteReqEx2(
File "C:\Users\MAP9AV\AppData\Local\Programs\Python\Python39\lib\site-packages\pyads\pyads_ex.py", line 774, in adsSyncReadWriteReqEx2
raise ADSError(err_code)
pyads.pyads_ex.ADSError: ADSError: Unknown Error (857212673).
I downloaded the gsuite developers python code from :
(https://github.com/gsuitedevs/python-samples)
I then enabled api access and downloaded the credentials.json file and ran the quickstart.py in:
(python-samples-master/slides/quickstart) and it worked and outputted
The presentation contains 5 slides:
- Slide #1 contains 4 elements.
- Slide #2 contains 11 elements.
- Slide #3 contains 9 elements.
- Slide #4 contains 5 elements.
- Slide #5 contains 12 elements.
So it worked. Then I tried to run test_snippets.py in:
(python-samples-master/slides/snippets)
And I get an error
======================================================================
ERROR: setUpClass (__main__.SnippetsTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "~/anaconda3/lib/python3.7/site-packages/oauth2client/client.py", line 1228, in _implicit_credentials_from_files
credentials_filename)
File "~/anaconda3/lib/python3.7/site-packages/oauth2client/client.py", line 1397, in _get_application_default_credential_from_file
AUTHORIZED_USER + "' or '" + SERVICE_ACCOUNT + "' values)")
oauth2client.client.ApplicationDefaultCredentialsError: 'type' field should be defined (and have one of the 'authorized_user' or 'service_account' values)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "test_snippets.py", line 32, in setUpClass
super(SnippetsTest, cls).setUpClass()
File "~/Desktop/python-samples-master/slides/snippets/base_test.py", line 27, in setUpClass
cls.credentials = cls.create_credentials()
File "~/Desktop/python-samples-master/slides/snippets/base_test.py", line 44, in create_credentials
credentials = GoogleCredentials.get_application_default()
File "~/anaconda3/lib/python3.7/site-packages/oauth2client/client.py", line 1271, in get_application_default
return GoogleCredentials._get_implicit_credentials()
File "~/anaconda3/lib/python3.7/site-packages/oauth2client/client.py", line 1256, in _get_implicit_credentials
credentials = checker()
File "~/anaconda3/lib/python3.7/site-packages/oauth2client/client.py", line 1231, in _implicit_credentials_from_files
extra_help, error)
File "~/anaconda3/lib/python3.7/site-packages/oauth2client/client.py", line 1429, in _raise_exception_for_reading_json
credential_file + extra_help + ': ' + str(error))
oauth2client.client.ApplicationDefaultCredentialsError: An error was encountered while reading json file: ~/Documents/credentials/credentials.json (pointed to by GOOGLE_APPLICATION_CREDENTIALS environment variable): 'type' field should be defined (and have one of the 'authorized_user' or 'service_account' values)
I definitely have a GOOGLE_APPLICATION_CREDENTIALS that points to the same credentials that successfully ran quickstart.py.
Is there something else I need or do I need to change some code to load the credentials data in?
It seems like GoogleCredentials.get_application_default() call is the one that is erroring
def create_credentials(cls):
credentials = GoogleCredentials.get_application_default()
scope = [
'https://www.googleapis.com/auth/drive',
]
return credentials.create_scoped(scope)
The file pointed to the environment variable GOOGLE_APPLICATION_CREDENTIALS is not a valid service account json file.
Open your service account json file. The beginning of the file should look similar to this:
{
"type": "service_account",
"project_id": "development-123456",
"private_key_id": "19c38bac6560abcdef01234567ac4da7991cbaad",
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANB
I am trying to do some text analysis:
def cleaning_text(sentence):
sentence=sentence.lower()
sentence=re.sub('\'','',sentence.strip())
sentence=re.sub('^\d+\/\d+|\s\d+\/\d+|\d+\-\d+\-\d+|\d+\-\w+\-\d+\s\d+\:\d+|\d+\-\w+\-\d+|\d+\/\d+\/\d+\s\d+\:\d+',' ',sentence.strip())# dates removed
sentence=re.sub(r'(.)(\/)(.)',r'\1\3',sentence.strip())
sentence=re.sub("(.*?\//)|(.*?\\\\)|(.*?\\\)|(.*?\/)",' ',sentence.strip())
sentence=re.sub('^\d+','',sentence.strip())
sentence = re.sub('[%s]' % re.escape(string.punctuation),'',sentence.strip())
cleaned=' '.join([w for w in sentence.split() if not len(w)<2 and w not in ('no', 'sc','ln') ])
cleaned=cleaned.strip()
if(len(cleaned)<=1):
return "NA"
else:
return cleaned
org_val=udf(cleaning_text,StringType())
df_new =df.withColumn("cleaned_short_desc", org_val(df["symptom_short_description_"]))
df_new =df_new.withColumn("cleaned_long_desc", org_val(df_new["long_description"]))
longWordsDF = (df_new.select(explode(split('cleaned_long_desc',' ')).alias('word'))
longWordsDF.count()
I get the following error.
File "<stdin>", line 2, in cleaning_text
AttributeError: 'NoneType' object has no attribute 'lower'
I want to perform word counts but any kind of aggregation function is giving me an error.
I tried following things:
sentence=sentence.encode("ascii", "ignore")
Added this statement in the cleaning_text function
df.dropna()
Its still giving the same issue, I do not know how to resolve this issue.
It looks like you have null values in some columns. Add an if at the beginning of cleaning_text function and the error will disappear:
if sentence is None:
return "NA"
I am using Chef provisioning to create machines in AWS. When creating the machine, I add an attribute to it that is an array of JSON files. In the recipes I run, I want to iterate over this array and create a template file on the machine. The machine gets provisioned but when iterating over the array attribute, I get an error that says:
undefined method `each' for nil:NilClass
I tried looking at the node file that got created on my server and guess what? The array of JSON files was added to the node file! I'm not sure why then it keeps throwing that error. Any ideas?
The code sample is as follows:
machines.rb
def get_cluster_json(domain_number)
clusters = []
##environment_template['domains'][domain_number]['clusters'].each do |cls|
clusters << JSON.parse(::File::read(new_resource.template_path + cls))
end
return clusters
end
provisioning_xyz_machine "test-admin" do
tag "usage:keep"
attribute "clusters_json", get_cluster_json(domain_counter)
recipe admin_role
machine_options get_machine_options()
ohai_hints ohai_hints
action $provisioningAction
end
admin_role.rb
managed_details = []
node["clusters_json"].each do |cls|
managed_details << "#{cls['cluster']['name']}"
end
Log
* template[/tools/appsw/appsautm/config/INTFIN_config] action create[2015-05-12T10:24:13-07:00] INFO: Processing template[/tools/appsw/appsautm/config/INTFIN_config] action create (xyz-environment-cookbook::build_admin line 32)
================================================================================
Error executing action `create` on resource 'template[/tools/appsw/appsautm/config/INTFIN_config]'
================================================================================
Chef::Mixin::Template::TemplateError
------------------------------------
undefined method 'each' for `nil:NilClass`
Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/xyz-environment-cookbook/recipes/build_admin.rb
32: template "/tools/appsw/appsautm/config/#{env_name}_config" do
33: source "#{env_name}_config.conf.erb"
34: cookbook "appsautm-template"
35: owner node['xyz-dir-library']['user']
36: mode "0755"
37:
38: variables({
39: :admin_servers=> admin_details,
40: :managed_servers=> managed_details
41: })
42: end
43:
Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/xyz-environment-cookbook/recipes/build_admin.rb:32:in `from_file'
The error appears to be in your template, not your cookbook. In fact, it appears completely unrelated to the files you posted. I'd need to see the #{env_name}_config.conf.erb file and the build_admin.rb file in order to be more help than that.
I'm trying to use a parameter expression in the plone.app.theming theming-controlpanel that gets a value from the portal_registry to use within the rules.xml file of the theme.
The goal is that if a boolean is set in the registry, the theme can allow/disallow certain content.
So my parameter expression (in theming-controlpanel) is
enable_ad_tags = python:context.portal_registry['lw.portal.enableadtags']
There is a corresponding boolean field in the portal_registry.
The rules.xml file has this rule:
<!-- Global Ad Tags -->
<drop css:theme="#globalAdTags" if="not($enable_ad_tags)" />
The problem is that on my local machine i get this error in the console all the time:
c2014-08-08 09:49:19 ERROR plone.transformchain Unexpected error whilst trying to apply transform chain
Traceback (most recent call last):
File "/Users/aaronwilliams/.buildout/eggs/plone.transformchain-1.0.3-py2.7.egg/plone/transformchain/transformer.py", line 48, in __call__
newResult = handler.transformIterable(result, encoding)
File "/Users/aaronwilliams/.buildout/eggs/plone.app.theming-1.1.1-py2.7.egg/plone/app/theming/transform.py", line 179, in transformIterable
params = prepareThemeParameters(findContext(self.request), self.request, parameterExpressions, cache)
File "/Users/aaronwilliams/.buildout/eggs/plone.app.theming-1.1.1-py2.7.egg/plone/app/theming/utils.py", line 630, in prepareThemeParameters
params[name] = quote_param(expression(expressionContext))
File "/Users/aaronwilliams/.buildout/eggs/Zope2-2.13.20-py2.7.egg/Products/PageTemplates/ZRPythonExpr.py", line 48, in __call__
return eval(self._code, vars, {})
File "PythonExpr", line 1, in <expression>
File "/Users/aaronwilliams/.buildout/eggs/AccessControl-3.0.6-py2.7-macosx-10.8-x86_64.egg/AccessControl/ImplPython.py", line 675, in guarded_getattr
v = getattr(inst, name)
AttributeError: 'DirectoryResource' object has no attribute 'portal_registry'
Is there a problem with the pattern I am trying to use here?
Is there a better/safer way to achieve this?
Using portal instead of context works:
enable_ad_tags = python:portal.portal_registry['lw.portal.enableadtags']
IMHO context should also work, or context does not behave like it does, or the naming is wrong.