脚本

Script attempted to create global variable

匿名 (未验证) 提交于 2019-12-03 01:48:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I would like to load one script into redis that will export functions that future scripts executed will depend on, but attempt to define global function fails, same goes for global variables: redis 127.0.0.1:6379> EVAL "function alex() return 3.1415 end" 0 (error) ERR Error running script (call to f_f24a5a054d91ccc74c2629e113f8f639bbedbfa2): user_script:1: Script attempted to create global variable 'alex' How can I define global functions and variables ? 回答1: Looking at the source code in file scripting.c /* This function installs

Cannot call Google Script API Functions from Web App (TypeError: Cannot read property 'run' of undefined)

匿名 (未验证) 提交于 2019-12-03 01:48:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I had a google apps script working fine for months and it suddenly stopped working. I'm wondering if Google deprecated some part of my code or something. This is the link to the file: Click here to view Google Spreadsheet File The google script code is apparently failing when trying to call a google script function from an HTML file. This is the line of code that fails. google.script.run.importCSVData(id); The lines fails and catches the following error: TypeError: Cannot read property 'run' of undefined Like I said, I had this code working

Fast ping sweep in python

匿名 (未验证) 提交于 2019-12-03 01:48:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: So, I'm trying to get similar results using python as I do with a bash script. Code for the bash script: #!/bin/bash for ip in $(seq 1 254); do ping -c 1 10.10.10.$ip | grep "bytes from" | cut -d " " -f 4 | cut -d ":" -f 1 & done The thing that I would like to do is get the same results with similar speed. The issue that I've had with every version of the python script is that it takes a very long time to complete compared to the few seconds the batch script takes. The batch file takes about 2 seconds to sweep a /24 network while the the

Running an R script using a Windows shortcut

匿名 (未验证) 提交于 2019-12-03 01:48:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I am trying to create an icon on my desktop (Windows OS). By clicking on this icon, an R script will be executed, which launches a GUI application ( gWidgets ). 回答1: Read the help file ?Startup for details on what R goes through in the startup process and how you can automate running code. I have done things like this for clients where I create a GUI for a specific demonstration (I use tcltk, but all should work the same). I created a desktop shortcut for them and modified the shortcut to start in a specific folder (but run the

Python script with arguments for command line Blender

匿名 (未验证) 提交于 2019-12-03 01:48:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm new to blender and python. I have a blender model (.blend) that I want to batch-render as several images providing some properties for each image. I wrote a python script with those parameters, something like: import bpy pi = 3.14159265 fov = 50 scene = bpy.data.scenes["Scene"] # Set render resolution scene.render.resolution_x = 480 scene.render.resolution_y = 359 # Set camera fov in degrees scene.camera.data.angle = fov*(pi/180.0) # Set camera rotation in euler angles scene.camera.rotation_mode = 'XYZ' scene.camera.rotation_euler[0] = 0

How to preview jsdoc comments in google doc scripts

匿名 (未验证) 提交于 2019-12-03 01:48:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I know that Issue 1731 has been raised requesting preview of jsdoc within the Google script editor. http://code.google.com/p/google-apps-script-issues/issues/detail?id=1731 While we wait for that to be implemented, what's the best way to preview jsdoc comments that I'm adding to my published library, without requiring me to create a new version? 回答1: Update 2014: With libraries now supported by the Google Apps Script editor's autocompletion, it's possible to get immediate feedback about SOME of your library's jsdoc comments. This solution

How to set environment variables in Jenkins?

匿名 (未验证) 提交于 2019-12-03 01:48:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I would like to be able to do something like: AOEU=$(echo aoeu) and have Jenkins set AOEU=aoeu . The Environment Variables section in Jenkins doesn't do that. Instead, it sets AOEU='$(echo aoeu)' . How can I get Jenkins to evaluate a shell command and assign the output to an environment variable? Eventually, I want to be able to assign the executor of a job to an environment variable that can be passed into or used by other scripts. 回答1: This can be done via EnvInject plugin in the following way: Create an "Execute shell" build step that

Importing installed package from script raises “AttributeError: module has no attribute” or “ImportError: cannot import name”

匿名 (未验证) 提交于 2019-12-03 01:48:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a script named requests.py that imports the requests package. The script either can't access attributes from the package, or can't import them. Why isn't this working and how do I fix it? The following code raises an AttributeError . import requests res = requests.get('http://www.google.ca') print(res) Traceback (most recent call last): File "/Users/me/dev/rough/requests.py", line 1, in import requests File "/Users/me/dev/rough/requests.py", line 3, in requests.get('http://www.google.ca') AttributeError: module 'requests' has no

My injected <script> runs after the target-page's javascript, despite using run_at: document_start?

匿名 (未验证) 提交于 2019-12-03 01:47:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am having some problem with the order of javascript execution when I use the content script to inject some javascript into the HTML page: This is my HTML page I use to test, test.html : Test Page This is the javascript I use to inject additional code into HTML page, injector.js : var s = document.createElement("script"); s.src = chrome.extension.getURL("inject.js"); document.documentElement.appendChild(s); console.log("Inject finished"); And this is the content of injected script, inject.js : console.log("Inside inject.js"); And finally,

Switching user in Fabric

匿名 (未验证) 提交于 2019-12-03 01:47:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a problem when using Fabric to mimic my SSH workflow to deploy my web application. Here's my usual flow of commands when I SSH to a server: SSH using root user. ssh root@1.2.3.4 Switch to web user: su - web Change directory: cd /srv/web/prod/abc_project Start virtualenv: workon abc_env Perform git pull: git pull origin master Run a script: build_stuff -m build Run another script: ./run I tried to write this as a deploy script in Fabric and I get a shell output when su - web is entered. I have to hit Ctrl-D to continue the script. I am