bulk account creation script not running and displaying confusing error messages - javascript

I'm trying to run a script I've successfully run in the past, to create accounts. Expected result: script executes and accounts are created. Current result: script does not execute, instead gives a series of error messages that don't seem related to the content of the script (screenshot below).
The first few lines of the script are just comments, followed by imports and arg parsing (image below).
The CSV is properly formatted and the path to it is correct. As far as I know, nothing in the script has changed since the last time I ran it successfully. Scripting is not my strong suit, would deeply appreciate pointers.

Your script is missing a shebang. The first line of the file should be:
#!/usr/bin/env node
Last time you probably explicitly ran it with node scripts/etc/yourfile.js instead of just scripts/etc/yourfile.js, which would have hidden this problem.

Related

AppScript onOpen not working. Log shows it triggers but no output, etc

I've been trying this for some time. What I'd like to do is upon sheet opening, copy a value from one cell to another. Seems simple enough. My latest iteration is this. (apologies in advance if I had made a typo, I'm hand transposing it from a different system). What I put below applies to either closing and opening the sheet or running the function via Apps Script interface.
function onOpen(e) {
SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Settings').getRange(2,6).setValue(SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Home').getRange(7,5).getValue())
}
Nothing happens. If I look in Executions log I can see onOpen triggered, without errors. If I put a Logger.log("Hello") in the function onOpen the execution log will not show the logged 'Hello'. If I put Logger.log("Hello") or Logger.log(SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Home').getRange(7,5).getValue()) in any other function and run it - I will see 'Hello' or the value in the Home sheet.
Any thoughts?
Posting my answer from the comments for future references:
Google Apps Script sometimes fails temporarily for a couple of minutes, so I would recommend creating a new script file, then paste the same code, delete the old one and try again.
This is a very common "behavior"/"bug" from Google Apps Script as somehow it gets "stuck" for a short period of time and I have heard from a lot of people that has had the same experience. I would recommend reporting this in Google's issue tracker showing your results to see if this can get fixed.
References:
Google's Issue Tracker

Return the results of running a program in realtime using Node.js?

Is there a way to run a program (for example: tcpdump) and every time it shows something through the console, from nodejs capture it and return the result to print in an html? no need to save it, keep it in real time.
My idea is that a program can be executed and while it is running and showing things in the console, they can be sent to the html where you can progressively see all the results of the program's execution.
Thanks for help.
I think using socket io is a good solution,
check there get started tutorial
No need to do anything like "capturing output" in Node.js. You can use the heredoc available in almost every shell. The heredoc, in the most basic sense, redirects the output of a command to a file. In your example, if you use tcpdump, here's what you'd do:
$ tcpdump [options] >> file.html
The >> heredoc operator appends to a file(create if doesn't exist). This means if you already have some content in file.html, the content will still be there, and the output will be appended to the end of the file.
The > heredoc writes to a file(also, create if doesn't exist). So, if you have some content in file.html, that will be overwritten with the new content.

Tests fail on travis, which pass local

My tests which turn green local, are getting red on travis. It's about this code:
And I change the year to "nineteen-ninenty-seven" # features/step_definitions/application_steps.rb:9
And I attempt to save the changes # features/step_definitions/application_steps.rb:17
Then I should see a message indicating that the data is invalid # features/step_definitions/application_steps.rb:26
expected to find text "Value must be of type integer." in "Provider configurations root name artist year" (RSpec::Expectations::ExpectationNotMetError)
./features/step_definitions/application_steps.rb:27:in `/^I should see a message indicating that the data is invalid$/'
features/editing_resources.feature:52:in `Then I should see a message indicating that the data is invalid'
This is in my support/capybara.rb
require 'capybara/cucumber'
require 'capybara/poltergeist'
Capybara.app = App.new
Capybara.javascript_driver = :poltergeist
Capybara.default_wait_time = 10
It's about this code:
When(/^I change the year to "(.*?)"$/) do |year|
find('input[name="root[year]"]').set year
end
When(/^I attempt to save the changes$/) do
find('input[type=submit]')
end
Then(/^I should see a message indicating that the data is invalid$/) do
expect(page).to have_content('Value must be of type integer.')
end
The problem:
When I run the tests local, they turn green. I debugged it there. I'm for sure that the code works well. The fields exist and get filled with the right data. When I use pry in my local tests on the point that I expect the message, I 'source' (or html), and I can find the text myself. On travis/ubuntu this doesn't work. I can confirm this doesn't work, cause I contacted Travis and they gave me a VM for a day where I duplicated the problem.
To solve it, I tried multiple things, I increased waiting time, tried selenium/webkit and selenium with chrome/firefox. They al work local, but I can't get them working properly on travis.
What I want to achieve is that the test validates if the user see's a messages which is getting created when a field isn't filled properly (text in integer field in this example).
The message is created by Json editor. https://github.com/jdorn/json-editor
And looks like this in code:
<small class="error">Value must be of type integer.</small>
A logic explanation in my opinion: in travis, the dom doesn't get the newest version which should load after an activity get's executed (like fill_in or set) and local this does work.
I hope somebody has an explanation and a solution.
Although I can't provide an answer for your exact problem, I can try to help you debug the issue with the information you provided.
Regarding Poltergeist:
Poltergeist allows you to take screenshots at specific points in your test
Depending on your tests, one thing that you may need is some fonts. If you're getting errors on a CI that don't occur during development then try taking some screenshots
I would try using page.save_screenshot before and after the points you identified and see what the differences are between local/travis.
EDIT: There is also a gem for capybara that takes screenshots whenever a test fails. Find more info here: Capybara-Screenshot

JavaScript: Unexpected End of Input... because it's only loading part of the file?

Strange error here: I have a page that's referencing several JavaScript files. Occasionally, the browser will complain of:
Uncaught SyntaxError: Unexpected end of input
However, it doesn't appear to be due to a missing parent, or malformed JSON. Part of the JavaScript file will load, but the program will just stop loading the rest of the file. Example: half of the file will load, with the other half missing.
Most of the time, the files load and everything works. Any idea why I would occasionally be getting this error, rather than every time (as expected with a missing paren or something similar)? Other things I can check?
EDIT:
This is a Rails project (Rails version 3.2).
The JS files are standalone, and are kept in the pub directory for dev. In other words, they are NOT included in the asset pipeline.
There must be braces not closed properly.The file stops loading whenever the error is encountered and leaves the rest part unloaded as because of error.
You can check this example here

Javascript .js loading issue

I am editing an existing site, which is a typical merchant site. A series of PHP files with one main index that loads in the various content pages.
The main index.php, using <script>, loads in jsFunctions.js.
When ever I modify the jsFunctions.js file, the index only loads the jsFunctions.js partially. For example I will get a firebug error such as 'unterminated string literal' or 'missing end }' or similar. The errors themselves make sense, because the js file isn't fully loading, a brace or quote is missing and throwing an error. It is seemingly random, sometimes it will load 100 lines of the js, then sometimes 105 lines, etc.
But why would the file be partially loading if i edit it? If i remove the single line of my code, no matter how simple, it starts working again?
Any ideas?
Are you editing a file with inconsistent line-endings, which editor? Issues like line-ending or weird unicode characters cause the issues like you've described.
I would take the contents of the file after your edit do a copy/paste exact as it is to JSLint: http://www.jslint.com/
JSLint is a validation tool for your script, before checking for best practices though, it'll check that your script is valid at all. See if you get the same error, it could be a weird character that's slipped in there causing issues, JSLint will alert you to this and where it's at.
Apparently it was some kind of server serving issue. If I refreshed a random amount of times, the full js would load. Once loaded it works 100% after that, well until I uploaded a new copy, then I would have to refresh a couple of times (or possibly wait 1-2 mins).
Filezilla was showing that the upload was complete, but the server simply didn't seem ready to output it.
Thanks guys

Categories