How to paste multi line code in Meteor shell - meteor

When I paste a multi line code like
const f = () => {
console.log("Hello");
};
in Meteor shell, it seems to be that every line is executed. I get this Error:
};
^
Uncaught SyntaxError: Unexpected token '}'
Is there a chance to paste multi line code in Meteor shell? It would be helpful in order to try out some code snippets.

Related

why the Python logging module throwing Attribute error?

I am working with the logging module for the first time. I was able to write the program as per my requirement. The logic written inside the try and except is also working almost successfully, and logs are getting generated in the log file. But for some reason I am seeing "AttributeError" on my IDE console for all the "logging.info" and "logging.exception". So, to cross verify I commented out all those location and this time my code ran without any error, but nothing was getting logged in the log file. Which was quite obvious. Below is the whole program
import logging
from logging.handlers import TimedRotatingFileHandler
logger = logging.handlers.TimedRotatingFileHandler('amitesh.log', when='midnight', interval=1)
logger.suffix = '%y_%m_%d.log'
# create a logging format
LOGGING_MSG_FORMAT = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
logger.setFormatter(LOGGING_MSG_FORMAT)
LOGGING_DATE_FORMAT = '%d-%b-%y %H:%M:%S'
# create basic configuration
logging.basicConfig(level=logging.INFO, format=LOGGING_MSG_FORMAT, datefmt=LOGGING_DATE_FORMAT)
root_logger = logging.getLogger('')
# add the handlers to the logger
root_logger.addHandler(logger)
while True:
print(" ")
print("This is a Logging demo")
print(" ")
logging.info("new request came")
print(" ")
try:
x = int(input("Enter the first number: "))
y = int(input("Enter the second number: "))
print(x / y)
except ZeroDivisionError as msg:
print("cannot divide with zero")
logging.exception(msg)
print(" ")
except ValueError as msg:
print("enter only integer value")
logging.exception(msg)
print(" ")
logging.info("executed successfully")
print(" ")
Below is the error message from my IDE console:
return self._fmt.find(self.asctime_search) >= 0
AttributeError: 'Formatter' object has no attribute 'find'
Call stack:
File "/Users/amitesh/PycharmProjects/Automation/Databases/DB_Conn.py", line 68, in <module>
logging.info("new request came")
Message: 'new request came'
Arguments: ()
I have gone through the internet in last 2 days without any luck.
Please help me figure out my mistake(s).
added more error:
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/logging/__init__.py", line 388, in usesTime
return self._fmt.find(self.asctime_search) >= 0
AttributeError: 'Formatter' object has no attribute 'find'
Call stack:
File "/Users/amitesh/PycharmProjects/Automation/Databases/DB_Conn.py", line 68, in <module>
logging.info("new request came")
Message: 'new request came'
Arguments: ()
Thank you.
Removed format=LOGGING_MSG_FORMAT, LOGGING_MSG_FORMAT and defined the values inside the basicConfig with "format" param directly as the parameter "format" takes a String not the type Formatter.

Gulp group media error "must start with number, buffer, array or string"

I use
var cmq = require('gulp-combine-media-queries')
gulp.task('cmq', function () {
gulp.src('css/style.css')
.pipe(cmq({
log: true
}))
.pipe(gulp.dest('dist'));
});
And this error is output after gulp command:
File css/style.css found.
buffer.js:169
throw new TypeError('must start with number, buffer, array or
string');
^
TypeError: must start with number, buffer, array or string
at fromObject (buffer.js:169:9)
at new Buffer (buffer.js:62:10)
at Transform.transform [as _transform] (/home/user/node_modules/gulp-
combine-media-queries/index.js:152:21)
at Transform._read (/home/user/node_modules/gulp-combine-media-
queries/node_modules/readable-stream/lib/_stream_transform.js:184:10)
at Transform._write (/home/user/node_modules/gulp-combine-media-
queries/node_modules/readable-stream/lib/_stream_transform.js:172:12)
at doWrite (/home/user/node_modules/gulp-combine-media-
queries/node_modules/readable-stream/lib/_stream_writable.js:237:10)
at writeOrBuffer (/home/user/node_modules/gulp-combine-media-
queries/node_modules/readable-stream/lib/_stream_writable.js:227:5)
at Transform.Writable.write (/home/user/node_modules/gulp-combine-
media-queries/node_modules/readable-
stream/lib/_stream_writable.js:194:11)
at write (/home/user/node_modules/vinyl-fs/node_modules/readable-
stream/lib/_stream_readable.js:623:24)
at flow (/home/user/node_modules/vinyl-fs/node_modules/readable-
stream/lib/_stream_readable.js:632:7)
at DestroyableTransform.pipeOnReadable (/home/user/node_modules/vinyl-
fs/node_modules/readable-stream/lib/_stream_readable.js:664:5)
at emitNone (events.js:67:13)
at DestroyableTransform.emit (events.js:166:7)
at emitReadable_ (/home/user/node_modules/vinyl-
fs/node_modules/readable-stream/lib/_stream_readable.js:448:10)
at emitReadable (/home/user/node_modules/vinyl-
fs/node_modules/readable-stream/lib/_stream_readable.js:444:5)
at readableAddChunk (/home/user/node_modules/vinyl-
fs/node_modules/readable-stream/lib/_stream_readable.js:187:9)
Node - 4.2.6, Gulp 3.9.1, npm - 3.5.2
I also used another npms for grouping media and have the same errors. I read many articles with the same problems, but none has helped
looking at media-query code (https://github.com/konitter/gulp-combine-media-queries/blob/master/index.js)
I could see that your file "css/style.css" is not accessible by gulp hence the error.
Please recheck the path and try again

mruby-require error: NoMethodError: undefined method 'puts' for main

I managed to compile the mruby code adding the mrubygem - mruby-require from https://github.com/mattn/mruby-require
However when I try to call the require './' I get an error. Below is my code:
inc.rb
def test(a, b)
print "Inside the include->test(..)"
return a+b
end
test1.rb
require 'inc.rb'
def helloworld(var1)
print 'hello world ' + var1 + ". Test number = " + test(4, 5)
end
helloworld('test')
When I execute test1.rb I get this error from mruby:
NoMethodError: undefined method 'puts' for main
After some analysis I found out the 'puts' is not working with mruby. Infact after adding mruby-require gem, no ruby code gets execute. Do I need to add any dependency with mruby-require?
Can someone help me please?
Update: Pasting the content of build_config.rb as requested. I have removed the lines which are commented.
build_config.rb
MRuby::Build.new do |conf|
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
toolchain :visualcpp
else
toolchain :gcc
end
enable_debug
# adding the mruby-require library
conf.gem 'mrbgems/mruby-require'
conf.gembox 'default'
end
MRuby::Build.new('host-debug') do |conf|
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
toolchain :visualcpp
else
toolchain :gcc
end
enable_debug
conf.gembox 'default'
conf.cc.defines = %w(ENABLE_DEBUG)
conf.gem :core => "mruby-bin-debugger"
end
The following quote is from its README.md:
When mruby-require is being used, additional mrbgems that appear after mruby-require in build_config.rb must be required to be used.
This is from your build_config.rb:
conf.gem 'mrbgems/mruby-require'
conf.gembox 'default'
The default gembox contains mruby-print. So either require mruby-print or preferably swap the lines to make it a built-in gem (the default behavior without mruby-require).

Custom command result

When invoking a custom command, I noticed that only the logs are displayed. For example, if my Custom Comand script contains a retrun statement return "great custom command", I can't find it in the result. Both in API Java client or shell execution cases.
What can I do to be able to retrieve that result at the end of an execution?
Thanks.
Command definition in service description file:
customCommands ([
"getText" : "getText.groovy"
])
getText.groovy file content:
def text = "great custom command"
println "trying to get a text"
return text
Assuming that you service file contains the following :
customCommands ([
"printA" : {
println "111111"
return "222222"
},
"printB" : "fileB.groovy"
])
And fileB.groovy contains the following code :
println "AAAAAA"
return "BBBBBB"
Then if you run the following command : invoke yourService printA
You will get this :
Invocation results:
1: OK from instance #1..., Result: 222222
invocation completed successfully.
and if you run the following command : invoke yourService printB
You will get this :
Invocation results:
1: OK from instance #1..., Result: AAAAAA
invocation completed successfully.
So if your custom command's implementation is a Groovy closure, then its result is its return value.
And if your custom command's implementation is an external Groovy file, then its result is its last statement output.
HTH,
Tamir.

How to create a file by registerMultiTask (gruntjs)

I want gruntjs to create a file on each build that contains some PHP code to define a version number.
the following code fragments are in my grunt.initConfig:
1st some meta
meta: {
versionfile: '<?php \n' +
'define(\'VERSION\', \'<%= grunt.template.today("yyyymmddhhii") =%>\'); \n' +
'?>'
}
2nd the configuration
versionfile: {
'lib/define-version.php': '<%= meta.versionfile %>'
}
and then the multitask definition
grunt.registerMultiTask('versionfile', 'create version file.', function() {
grunt.file.write(this.target, this.data);
});
when I run the job the following error comes up and the file is not written:
Running "versionfile:lib/define-version.php" (versionfile) task
Warning: An error occurred while processing a template (Unexpected token )). Use --force to continue.
I am thankful for every hint on what exactly this error means.
Maybe there is another way to write a file containing the php-code?
I found the error. The correct configuration has a = too much.
Instead of
'define(\'VERSION\', \'<%= grunt.template.today("yyyymmddhhii") =%>\'); \n' +
it must be
'define(\'VERSION\', \'<%= grunt.template.today("yyyymmddhhMM") %>\'); \n' +
(ignore the ii>MM, that's just another error ;)

Resources