Bitbucket Pipelines export into variable using jq and xq causes error - linux

When i running a pipeline in bitbucket i want to export into variable using
export APEX_CLASSES=$(xq . < package/package.xml | jq '.Package.types | [.] | flatten | map(select(.name=="ApexClass")) | .[] | .members | [.] | flatten | map(select(. | index("*") | not)) | unique | join(",")' -r)
but i got error in pipeline
parse error: Invalid numeric literal at line 1, column 5
i tried to identify a error but i always get same error :(
When i add a escape \ before " i got this error
jq: error: syntax error, unexpected INVALID_CHARACTER (Unix shell quoting issues?) at <top-level>, line 1:
.Package.types | [.] | flatten | map(select(.name==\"ApexClass\")) | .[] | .members | [.] | flatten | map(select(. | index(\"*\") | not)) | unique | join(\",\")
jq: 1 compile error
This is package.xml
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>AccountHelper</members>
<members>BoatHelper</members>
<members>CaseHelper</members>
<name>ApexClass</name>
</types>
<version>57.0</version>
</Package>

Related

Unable to connect to the PYMQI Client facing FAILED: MQRC_ENVIRONMENT_ERROR

I am getting the below error while connecting to IBM MQ using library pymqi.
Its a clustered MQ channel
Traceback (most recent call last):
File "postToQueue.py", line 432, in <module>
qmgr = pymqi.connect(queue_manager, channel, conn_info)
File "C:\Python\lib\site-packages\pymqi\__init__.py", line 2608, in connect
qmgr.connect_tcp_client(queue_manager or '', CD(), channel, conn_info, user, password)
File "C:\Python\lib\site-packages\pymqi\__init__.py", line 1441, in connect_tcp_client
self.connect_with_options(name, cd, user=user, password=password)
File "C:\Python\lib\site-packages\pymqi\__init__.py", line 1423, in connect_with_options
raise MQMIError(rv[1], rv[2])
pymqi.MQMIError: MQI Error. Comp: 2, Reason 2012: FAILED: MQRC_ENVIRONMENT_ERROR'
Please see my code below.
queue_manager = 'quename here'
channel = 'channel name here'
host ='host-name here'
port = '2333'
queue_name = 'queue name here'
message = 'my message here'
conn_info = '%s(%s)' % (host, port)
print(conn_info)
qmgr = pymqi.connect(queue_manager, channel, conn_info)
queue = pymqi.Queue(qmgr, queue_name)
queue.put(message)
print("message sent")
queue.close()
qmgr.disconnect()
Getting error at the line below
qmgr = pymqi.connect(queue_manager, channel, conn_info)
Added the IBM client to scripts folder as well , using Windows 10 , Python 3.8.1 and IBM Client 9.1 windows client installation image, Below is the header
-----------------------------------------------------------------------------+
| |
| WebSphere MQ First Failure Symptom Report |
| ========================================= |
| |
| Date/Time :- Tue January 28 2020 16:27:51 Eastern Standard Time |
| UTC Time :- 1580246871.853000 |
| UTC Time Offset :- -300 (Eastern Standard Time) |
| Host Name :- CA-LDLD0SQ2 |
| Operating System :- Windows 10 Enterprise x64 Edition, Build 17763 |
| PIDS :- 5724H7251 |
| LVLS :- 8.0.0.11 |
| Product Long Name :- IBM MQ for Windows (x64 platform) |
| Vendor :- IBM |
| O/S Registered :- 0 |
| Data Path :- C:\Python\Scripts\IBM |
| Installation Path :- C:\Python |
| Installation Name :- MQNI08000011 (126) |
| License Type :- Unknown |
| Probe Id :- XC207013 |
| Application Name :- MQM |
| Component :- xxxInitialize |
| SCCS Info :- F:\build\slot1\p800_P\src\lib\cs\amqxeida.c, |
| Line Number :- 5085 |
| Build Date :- Dec 12 2018 |
| Build Level :- p800-011-181212.1 |
| Build Type :- IKAP - (Production) |
| UserID :- alekhya.machiraju |
| Process Name :- C:\Python\python.exe |
| Arguments :- |
| Addressing mode :- 32-bit |
| Process :- 00010908 |
| Thread :- 00000001 |
| Session :- 00000001 |
| UserApp :- TRUE |
| Last HQC :- 0.0.0-0 |
| Last HSHMEMB :- 0.0.0-0 |
| Last ObjectName :- |
| Major Errorcode :- xecF_E_UNEXPECTED_SYSTEM_RC |
| Minor Errorcode :- OK |
| Probe Type :- INCORROUT |
| Probe Severity :- 2 |
| Probe Description :- AMQ6090: MQM could not display the text for error |
| 536895781. |
| FDCSequenceNumber :- 0 |
| Comment1 :- WinNT error 1082155270 from Open ccsid.tbl. |
| |
+-----------------------------------------------------------------------------+

How can i import a class in python file from my airflow custom operator?

How can i import a class in bar.py from my operator?
i have a folder structure like this
.
+--dags
+--libs
| +--__init__.py
| +--foo
| +--__init__.py
| +--bar.py
+--plugins
| +-- foo_operators.py
In foo_operators.py
from libs.foo.bar import Client
but i got an error, it cannot find the class
How about you move libs into dags?
.
+--dags
| +--libs
| +--__init__.py
| +--foo
| +--__init__.py
| +--bar.py
+--plugins
| +-- foo_operators.py

SCons does not find file it should build itself

I have a simple SConstruct file to build the google test library with MinGW:
env = Environment(platform='posix') # necessary to use gcc and not MS
env.Append(CPPPATH=['googletest/'])
env.Append(CCFLAGS=[('-isystem', 'googletest/include/'), '-pthread'])
obj = env.Object(source='googletest/src/gtest-all.cc')
# linking skipped due to error search
# env.Append(LINKFLAGS=['-rv'])
# bin = env.StaticLibrary(target='libgtest', source=[obj])
The script resides in the main googletest\ folder. When running it - with or without linking - the output is this:
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
g++ -o googletest\src\gtest-all.o -c -isystem googletest/include/ -pthread -Igoogletest googletest\src\gtest-all.cc
scons: *** [googletest\src\gtest-all.o] The system cannot find the file specified
+-.
+-googletest
| +-googletest\src
| +-googletest\src\gtest-all.cc
| +-googletest\src\gtest-all.o
| | +-googletest\src\gtest-all.cc
| | +-googletest\src\gtest-death-test.cc
| | +-googletest\src\gtest-filepath.cc
| | +-googletest\src\gtest-port.cc
| | +-googletest\src\gtest-printers.cc
| | +-googletest\src\gtest-test-part.cc
| | +-googletest\src\gtest-typed-test.cc
| | +-googletest\src\gtest.cc
| | +-googletest\src\gtest-internal-inl.h
| +-googletest\src\gtest-death-test.cc
| +-googletest\src\gtest-filepath.cc
| +-googletest\src\gtest-internal-inl.h
| +-googletest\src\gtest-port.cc
| +-googletest\src\gtest-printers.cc
| +-googletest\src\gtest-test-part.cc
| +-googletest\src\gtest-typed-test.cc
| +-googletest\src\gtest.cc
| +-googletest\src\libgtest-all.a
| +-googletest\src\gtest-all.o
| +-googletest\src\gtest-all.cc
| +-googletest\src\gtest-death-test.cc
| +-googletest\src\gtest-filepath.cc
| +-googletest\src\gtest-port.cc
| +-googletest\src\gtest-printers.cc
| +-googletest\src\gtest-test-part.cc
| +-googletest\src\gtest-typed-test.cc
| +-googletest\src\gtest.cc
| +-googletest\src\gtest-internal-inl.h
+-SConstruct
scons: building terminated because of errors.
I also tried to build the library in one line: env.StaticLibrary(source='googletest/src/gtest-all.cc') - the result is the same.
Just executing the actuall g++ call gives me the object file I want.
What confuses me is that SCons should see the object file as an artifact it creates itself. I wondering why it tries to use it before it is finished. So what am I missing here? How can I make SCons wait until the compiling is done?
BTW: I just have some experience in using SCons and and did tweak a script once a while - but I do not really have profound knowledger about it.
Versions used: SCons 3.0.1, Python 3.6.3, MinGW 7.3.0
Does this work?
env = Environment(tools=['mingw','gnulink','ar']) # You should specify the tools
env.Append(CPPPATH=['googletest/'])
env.Append(CCFLAGS=[('-isystem', 'googletest/include/'), '-pthread'])
obj = env.Object(source='googletest/src/gtest-all.cc')
# linking skipped due to error search
# env.Append(LINKFLAGS=['-rv'])
# bin = env.StaticLibrary(target='libgtest', source=[obj])

Linux man command about [OPTIONS]

Let's say git add command.When I input man git add,I get its page.
SYNOPSIS
git add [--verbose | -v] [--dry-run | -n] [--force | -f] [--interactive | -i] [--patch | -p]
[--edit | -e] [--[no-]all | --[no-]ignore-removal | [--update | -u]]
[--intent-to-add | -N] [--refresh] [--ignore-errors] [--ignore-missing]
[--] [<pathspec>...]
I have two quesions:
git add --verbose is same as git add -v?
for other command such as git,python , --fullNameA is same as -A? (fullNameA is abbreviated to A)
Each option in [--xxx | -x] characters are the same, so [--verbose | -v] means that --verbose will do the same as -v. This is true for all the man pages.

How to include modules for code coverage for unit testing?

My assumption is that any module tested using Intern will automatically be covered by Istanbul's code coverage. For reasons unknown to me, my module is not being included.
I am:
running Intern 1.6.2 (installed with npm locally)
testing NodeJS code
using callbacks, not promises
using CommonJS modules, not AMD modules
Directory Structure (only showing relevant files):
plister
|
|--libraries
| |--file-type-support.js
|
|--tests
| |--intern.js
| |--unit
| |--file-type-support.js
|
|--node_modules
|--intern
plister/tests/intern.js
define({
useLoader: {
'host-node': 'dojo/dojo'
},
loader: {
packages: [
{name: 'libraries', location: 'libraries'}
]
},
reporters: ['console'],
suites: ['tests/unit/file-type-support'],
functionalSuites: [],
excludeInstrumentation: /^(tests|node_modules)\//
});
plister/tests/unit/file-type-support.js
define([
'intern!bdd',
'intern/chai!expect',
'intern/dojo/node!fs',
'intern/dojo/node!path',
'intern/dojo/node!stream-equal',
'intern/dojo/node!../../libraries/file-type-support'
], function (bdd, expect, fs, path, streamEqual, fileTypeSupport) {
'use strict';
bdd.describe('file-type-support', function doTest() {
bdd.it('should show that the example output.plist matches the ' +
'temp.plist generated by the module', function () {
var deferred = this.async(),
input = path.normalize('tests/resources/input.plist'),
output = path.normalize('tests/resources/output.plist'),
temporary = path.normalize('tests/resources/temp.plist');
// Test deactivate function by checking output produced by
// function against test output.
fileTypeSupport.deactivate(fs.createReadStream(input),
fs.createWriteStream(temporary),
deferred.rejectOnError(function onFinish() {
streamEqual(fs.createReadStream(output),
fs.createReadStream(temporary),
deferred.callback(function checkEqual(error, equal) {
expect(equal).to.be.true;
}));
}));
});
});
});
Output:
PASS: main - file-type-support - should show that the example output.plist matches the temp.plist generated by the module (29ms)
1/1 tests passed
1/1 tests passed
Output (on failure):
FAIL: main - file-type-support - should show that the example output.plist matches the temp.plist generated by the module (30ms)
AssertionError: expected true to be false
AssertionError: expected true to be false
0/1 tests passed
0/1 tests passed
npm ERR! Test failed. See above for more details.
npm ERR! not ok code 0
Output (after removing excludeInstrumentation):
PASS: main - file-type-support - should show that the example output.plist matches the temp.plist generated by the module (25ms)
1/1 tests passed
1/1 tests passed
------------------------------------------+-----------+-----------+-----------+-----------+
File | % Stmts |% Branches | % Funcs | % Lines |
------------------------------------------+-----------+-----------+-----------+-----------+
node_modules/intern/ | 70 | 50 | 100 | 70 |
chai.js | 70 | 50 | 100 | 70 |
node_modules/intern/lib/ | 79.71 | 42.86 | 72.22 | 79.71 |
Test.js | 79.71 | 42.86 | 72.22 | 79.71 |
node_modules/intern/lib/interfaces/ | 80 | 50 | 63.64 | 80 |
bdd.js | 100 | 100 | 100 | 100 |
tdd.js | 76.19 | 50 | 55.56 | 76.19 |
node_modules/intern/lib/reporters/ | 56.52 | 35 | 57.14 | 56.52 |
console.js | 56.52 | 35 | 57.14 | 56.52 |
node_modules/intern/node_modules/chai/ | 37.9 | 8.73 | 26.38 | 39.34 |
chai.js | 37.9 | 8.73 | 26.38 | 39.34 |
tests/unit/ | 100 | 100 | 100 | 100 |
file-type-support.js | 100 | 100 | 100 | 100 |
------------------------------------------+-----------+-----------+-----------+-----------+
All files | 42.14 | 11.35 | 33.45 | 43.63 |
------------------------------------------+-----------+-----------+-----------+-----------+
My module passes the test and I can make it fail too. It just will not show up in the code coverage. I have done the tutorial hosted on GitHub without any problems.
I tried dissecting the Istanbul and Intern dependencies. I place a console.log where it seems files to be covered go through, but my module doesn't get passed. I have tried every variation of deferred.callback and deferred.rejectOnError with no difference to the code coverage.
Also, any feedback on my use of deferred.callback and deferred.rejectOnError will be greatly appreciated. I am still a little uncertain on their usage.
Thanks!
As of Intern 1.6, only require('vm').runInThisContext is hooked to add code coverage data, not require. Instrumentation of require was added in Intern 2.0.
The use of callback/rejectOnError in the above code is correct.

Resources