Bad substitution using sh - sh

I have the following script and I'm getting the following error: Error: Bad substitution
value="$(cat temp.txt)"
valueWOBegin="$(echo ${value/*====BUILDTYPES====/})"
valueWOEnd="$(echo ${valueWOBegin/====END BUILDTYPES====*/})"
This is the temp.txt file
====BUILDTYPES==== [BuildType_Decorated{name=debug, debuggable=true, testCoverageEnabled=false, jniDebuggable=false,
pseudoLocalesEnabled=false, renderscriptDebuggable=false,
renderscriptOptimLevel=3, minifyEnabled=false, zipAlignEnabled=true,
signingConfig=SigningConfig_Decorated{name=debug,
storeFile=/mypath/debug.keystore, storePassword=android,
keyAlias=AndroidDebugKey, keyPassword=android, storeType=jks,
v1SigningEnabled=true, v2SigningEnabled=true,
v1SigningConfigured=false, v2SigningConfigured=false},
embedMicroApp=false, mBuildConfigFields={}, mResValues={},
mProguardFiles=[], mConsumerProguardFiles=[],
mManifestPlaceholders={}}, BuildType_Decorated{name=release,
debuggable=false, testCoverageEnabled=false, jniDebuggable=false,
pseudoLocalesEnabled=false, renderscriptDebuggable=false,
renderscriptOptimLevel=3, minifyEnabled=true, zipAlignEnabled=true,
signingConfig=null, embedMicroApp=true, mBuildConfigFields={},
mResValues={},
mProguardFiles=[/mypath/proguard-rules.pro],
mConsumerProguardFiles=[], mManifestPlaceholders={}}]
====END BUILDTYPES====

Related

gnu-prolog - initialization predicate failing

In compiling and running the code below (pl_check_input.pl), I get "user directive failed" on the ":- initialization..." line
:- dynamic(doit/0).
:- initialization(doit).
:- include(head).
doit :-
readFB(user_input),
writeFB,
halt.
:- include(tail).
$ gplc --no-del-temp --no-top-level pl_check_input.pl
$ ./pl_check_input <fb1 >fb2
warning: /home/tarvydas/Dropbox/Projects/vsh/pl-vsh/pl_check_input.pl:2: user directive failed
If I remove the offending line
:- dynamic(doit/0).
:- include(head).
doit :-
readFB(user_input),
writeFB,
halt.
:- include(tail).
$ gplc --no-del-temp --no-top-level pl_check_input.pl
$ ./pl_check_input <fb1 >fb2
Warning: no initial goal executed
use a directive :- initialization(Goal)
or remove the link option --no-top-level (or --min-bips or --min-size)
Any insights would be very welcome.
Ultimately, I have this code running from the REPL, but I want to put it in a linux pipeline script and remove the various banner lines that come with top-level/0.
"never mind", it turned out to be a missing rule that generated a very misleading error message. To duplicate the error, create junk.pl:
:- initialization(main).
:- include(head).
main :-
readFB(user_input),
writeFB,
halt.
:- include(tail).
and create file head.pl:
:- dynamic(component/1) .
:- dynamic(edge/1) .
create file tail.pl (the first commented out line is the missing rule)
% writeterm(Term) :- current_output(Out), write_term(Out, Term, []), write(Out, '.'), nl.
writeFB :-
forall(component(X), writeterm(component(X))),
forall(edge(X), writeterm(edge(X))).
readFB(Str) :-
read_term(Str,T0,[]),
element(T0,Str).
element(end_of_file, _) :- !.
element(component(X), Str) :- !,
asserta(component(X)),
readFB(Str).
element(edge(X), Str) :- !,
asserta(edge(X)),
readFB(Str).
create file fb1a:
component('pl_vsh') .
edge(e0) .
then run a compile and execute the command:
$ gplc junk.pl --no-top-level
$ ./junk <fb1a >fb2
which results in the error message:
warning: /home/xxx/xxx/xxx/xxx/xxx/junk.pl:1: user directive failed

ERROR: Uncaught exception in luigi (TypeError: must be string or buffer, not None)

I am having trouble while calling /triggering Luigi Task from a python code.
Basically i need to trigger a luigi task just like we do on command line, but from a python code
I am using supbrocess.popen to call a luigi task using a shell
command
I have a test code named as test.py and have a test class in module
task_scheduler.py which contains my luigi task (both modules in same location/dir)
import luigi
class TestClass(luigi.Task):
# param = luigi.DictParameter(default=dict())
def requires(self):
print "I am TestClass req"
def run(self):
with open('myfile.txt', 'w') as f:
f.write("asasasas")
print "I am TestClass run"
import subprocess
p = subprocess.Popen("python -m luigi --module task_scheduler TestClass", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
print p.pid
(output, err) = p.communicate()
print "-------------O/P-------------"
print output
print "-------------error-------------"
print err
But I am getting the error as
52688
-------------O/P-------------
-------------error-------------
ERROR: Uncaught exception in luigi
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/luigi/retcodes.py", line 61, in run_with_retcodes
worker = luigi.interface._run(argv)['worker']
File "/Library/Python/2.7/site-packages/luigi/interface.py", line 238, in _run
return _schedule_and_run([cp.get_task_obj()], worker_scheduler_factory)
File "/Library/Python/2.7/site-packages/luigi/interface.py", line 172, in _schedule_and_run
not(lock.acquire_for(env_params.lock_pid_dir, env_params.lock_size, kill_signal))):
File "/Library/Python/2.7/site-packages/luigi/lock.py", line 82, in acquire_for
my_pid, my_cmd, pid_file = get_info(pid_dir)
File "/Library/Python/2.7/site-packages/luigi/lock.py", line 67, in get_info
pid_file = os.path.join(pid_dir, hashlib.md5(cmd_hash).hexdigest()) + '.pid'
TypeError: must be string or buffer, not None
Can anyone please suggest me what I am doing wrong here?
The command "python -m luigi --module task_scheduler TestClass" works perfectly if I use shell prompt
I just tried executing the test.py from command line.
It seems when I was using the IDE to run (PyCharm) then only it gives this issue
This is fixed in version 2.2.0. Check github issue #1654

Annotating a corpus using Syntaxnet

I am trying to annotate a corpus using Syntaxnet. I added the following lines in the end of the /models/syntaxnet/syntaxnet/models/parsey_mcparseface/context.pbtxt file:
input {
name: 'input_file'
record_format: 'english-text'
Part {
file_pattern: '/home/melvyn/text.txt'
}
}
output {
name: 'output_file'
record_format: 'english-text'
Part {
file_pattern: '/home/melvyn/text-tagged.txt'
}
}
When i run the command:
./demo.sh --input=input_file --output=output_file
I am getting:
./demo.sh: line 31: bazel-bin/syntaxnet/parser_eval: No such file or directory
./demo.sh: line 43: bazel-bin/syntaxnet/parser_eval: No such file or directory
./demo.sh: line 55: bazel-bin/syntaxnet/conll2tree: No such file or directory
According to the answer given ## here ## I changed my demo.sh file and now I get some errors which say:
[libprotobuf ERROR external/tf/google/protobuf/src/google/protobuf/text_format.cc:291] Error parsing text-format syntaxnet.TaskSpec: 200:8: Message type "syntaxnet.TaskOutput" has no field named "Part".
E external/tf/tensorflow/core/framework/op_segment.cc:53] Create kernel failed: Invalid argument: Could not parse task context at syntaxnet/models/parsey_mcparseface/context.pbtxt
E external/tf/tensorflow/core/common_runtime/executor.cc:333] Executor failed to create kernel. Invalid argument: Could not parse task context at syntaxnet/models/parsey_mcparseface/context.pbtxt
[[Node: DocumentSource = DocumentSourcebatch_size=32, corpus_name="stdin-conll", task_context="syntaxnet/models/parsey_mcparseface/context.pbtxt", _device="/job:localhost/replica:0/task:0/cpu:0"]]
What could be a possible solution?
Though it's not certain but I think you are not running the shell script from the root directory. Please try running it as per the instructions mentioned here
I hope it helps.

Issue with multiline TokenInputTransformer in IPython extension

I am trying to use a TokenInputTransformer within an IPython extension module, but it seems that there is something wrong with the standard implementation of token transformers with multiline input. Consider the following minimal extension:
from IPython.core.inputtransformer import TokenInputTransformer
#TokenInputTransformer.wrap
def test_transformer(tokens):
return tokens
def load_ipython_extension(ip):
for s in (ip.input_splitter, ip.input_transformer_manager):
s.python_line_transforms.extend([test_transformer()])
print "Test activated"
When I load the extension in IPython 1.1.0 I get a non-handled exception with multiline input:
In [1]: %load_ext test
Test activated
In [2]: abs(
...: 2
...: )
Traceback (most recent call last):
File "/Applications/anaconda/bin/ipython", line 6, in <module>
sys.exit(start_ipython())
File "/Applications/anaconda/lib/python2.7/site-packages/IPython/__init__.py", line 118, in start_ipython
return launch_new_instance(argv=argv, **kwargs)
File "/Applications/anaconda/lib/python2.7/site-packages/IPython/config/application.py", line 545, in launch_instance
app.start()
File "/Applications/anaconda/lib/python2.7/site-packages/IPython/terminal/ipapp.py", line 362, in start
self.shell.mainloop()
File "/Applications/anaconda/lib/python2.7/site-packages/IPython/terminal/interactiveshell.py", line 436, in mainloop
self.interact(display_banner=display_banner)
File "/Applications/anaconda/lib/python2.7/site-packages/IPython/terminal/interactiveshell.py", line 548, in interact
self.input_splitter.push(line)
File "/Applications/anaconda/lib/python2.7/site-packages/IPython/core/inputsplitter.py", line 620, in push
out = self.push_line(line)
File "/Applications/anaconda/lib/python2.7/site-packages/IPython/core/inputsplitter.py", line 655, in push_line
line = transformer.push(line)
File "/Applications/anaconda/lib/python2.7/site-packages/IPython/core/inputtransformer.py", line 152, in push
return self.output(tokens)
File "/Applications/anaconda/lib/python2.7/site-packages/IPython/core/inputtransformer.py", line 157, in output
return untokenize(self.func(tokens)).rstrip('\n')
File "/Applications/anaconda/lib/python2.7/site-packages/IPython/utils/_tokenize_py2.py", line 276, in untokenize
return ut.untokenize(iterable)
File "/Applications/anaconda/lib/python2.7/site-packages/IPython/utils/_tokenize_py2.py", line 214, in untokenize
self.add_whitespace(start)
File "/Applications/anaconda/lib/python2.7/site-packages/IPython/utils/_tokenize_py2.py", line 199, in add_whitespace
assert row >= self.prev_row
AssertionError
If you suspect this is an IPython bug, please report it at:
https://github.com/ipython/ipython/issues
or send an email to the mailing list at ipython-dev#scipy.org
You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.
Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
%config Application.verbose_crash=True
Am I doing something wrong or is it really an IPython bug?
It is really an IPython bug, I think. Specifically, the way we handle tokenize fails when an expression involving brackets (()[]{}) is spread over more than one line. I'm trying to work out what we can do about this.
Kinda late answer but, I was trying to use it in my own extension and just had the same problem. I've solved it by simply removing NL from the list (it's not the same as NEWLINE token which end statement), NL token only appears inside [], (), {} so it should be safely removable.
from tokenize import NL
#TokenInputTransformer.wrap
def mat_transformer(tokens):
tokens = list(filter(lambda t: t.type != NL, tokens))
return tokens
If you are looking for full example, I've posted my goofy code there: https://github.com/Quinzel/pymat

windows r inside rcpp eclipse

I'm trying to use Rinside in an IDE, Eclipse. Follow step by step manual
http://blog.fellstat.com/?p=170
However, when you Build All I mark the following errors
C:/R/R-2.15.2/library/Rcpp/include/Rcpp/string.h:55:17: error: 'internal' does not name a type
C:/R/R-2.15.2/library/Rcpp/include/Rcpp/string.h:68:21: error: expected ')' before 'charsxp'
C:/R/R-2.15.2/library/Rcpp/include/Rcpp/string.h:73:23: error: 'StringProxy' does not name a type
C:/R/R-2.15.2/library/Rcpp/include/Rcpp/string.h:73:36: error: ISO C++ forbids declaration of 'proxy' with no type [-fpermissive]
C:/R/R-2.15.2/library/Rcpp/include/Rcpp/string.h:92:23: error: expected ')' before 'x'
C:/R/R-2.15.2/library/Rcpp/include/Rcpp/string.h:97:35: error: declaration of 'operator=' as non-function
C:/R/R-2.15.2/library/Rcpp/include/Rcpp/string.h:97:32: error: expected ';' at end of member declaration
C:/R/R-2.15.2/library/Rcpp/include/Rcpp/string.h:97:41: error: expected ')' before 'x'
C:/R/R-2.15.2/library/Rcpp/include/Rcpp/string.h:100:35: error: declaration of 'operator=' as non-function
C:/R/R-2.15.2/library/Rcpp/include/Rcpp/string.h:100:32: error: expected ';' at end of member declaration
C:/R/R-2.15.2/library/Rcpp/include/Rcpp/string.h:100:40: error: expected ')' before 'x'
C:/R/R-2.15.2/library/Rcpp/include/Rcpp/string.h:103:41: error: 'StringProxy' does not name a type
C:/R/R-2.15.2/library/Rcpp/include/Rcpp/string.h:103:54: error: ISO C++ forbids declaration of 'proxy' with no type [-fpermissive]
C:/R/R-2.15.2/library/Rcpp/include/Rcpp/string.h:125:42: error: 'StringProxy' does not name a type
C:/R/R-2.15.2/library/Rcpp/include/Rcpp/string.h:125:55: error: ISO C++ forbids declaration of 'proxy' with no type [-fpermissive]
C:/R/R-2.15.2/library/Rcpp/include/Rcpp/string.h:133:36: error: declaration of 'operator+=' as non-function
C:/R/R-2.15.2/library/Rcpp/include/Rcpp/string.h:133:32: error: expected ';' at end of member declaration
C:/R/R-2.15.2/library/Rcpp/include/Rcpp/string.h:133:41: error: expected ')' before 'x'
In file included from c:\r\rtools\gcc-4.6.3\bin\../lib/gcc/i686-w64-mingw32/4.6.3/../../../../include/c++/4.6.3/cwchar:46:0,
from c:\r\rtools\gcc-4.6.3\bin\../lib/gcc/i686-w64-mingw32/4.6.3/../../../../include/c++/4.6.3/bits/postypes.h:42,
from c:\r\rtools\gcc-4.6.3\bin\../lib/gcc/i686-w64-mingw32/4.6.3/../../../../include/c++/4.6.3/iosfwd:42,
from c:\r\rtools\gcc-4.6.3\bin\../lib/gcc/i686-w64-mingw32/4.6.3/../../../../include/c++/4.6.3/ios:39,
from c:\r\rtools\gcc-4.6.3\bin\../lib/gcc/i686-w64-mingw32/4.6.3/../../../../include/c++/4.6.3/ostream:40,
from c:\r\rtools\gcc-4.6.3\bin\../lib/gcc/i686-w64- mingw32/4.6.3/../../../../include/c++/4.6.3/iterator:64,
from C:/R/R-2.15.2/library/Rcpp/include/RcppCommon.h:57,
from C:/R/R-2.15.2/library/Rcpp/include/Rcpp.h:27,
from ../src/main.cpp:12:
c:\r\rtools\gcc-4.6.3\bin\../lib/gcc/i686-w64-mingw32/4.6.3/../../../../i686-w64- mingw32/include/wchar.h:12:32: error: expected '}' before end of line
In file included from C:/R/R-2.15.2/include/R_ext/RS.h:26:0,
from C:/R/R-2.15.2/include/R.h:44,
from C:/R/R-2.15.2/library/Rcpp/include/RcppCommon.h:32,
from C:/R/R-2.15.2/library/Rcpp/include/Rcpp.h:27,
from ../src/main.cpp:12:
And the error list continues
Somebody help me, really I did everything and nothing helps.
thanks