anaconda build system don't work in sublime text 3 - anaconda

eve : virtual box ubuntu16.04
I installed sublime text 3, and installed the plugin-in anaconda.
i configured the Anaconda.sublime-settings:
{
"anaconda_linting" : false,
"swallow_startup_errors": true,
"python_interpreter": "/home/cgy/soft/anaconda3/bin/python"
}
it's seem all ok, but when i make an .py file and build it ,such as that:
import pandas as pd
print("hello")
Can't find the build system, then i do that:tools->build system->new build system
create an file,and the content is that:
{
"shell_cmd": ["/home/cgy/soft/anaconda3/python", "-u", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python"
}
but the sublime console just out put:
File "/home/cgy/soft/sublime_text_3/sublime_plugin.py", line 795, in run_
return self.run(**args)
File "exec in /home/cgy/soft/sublime_text_3/Packages/Default.sublime-
package", line 238, in run
TypeError: Can't convert 'list' object to str implicitly
what's wrong it and how should i do to solve it?
thank you.

That error message is being generated because your build system is incorrectly using shell_cmd when you seem to have meant cmd instead.
If you use shell_cmd, the value should be a string that represents exactly what you would type into a command prompt, complete with things like redirection, && to chain commands, etc.
If you use cmd, the value should be an array of strings, where the first one is the name of the thing to run and the rest are the arguments.
To fix your problem you need to use cmd instead, or convert the list of strings into a complete string. If you go the latter route, be sure that you remember that you need to take care of quoting things like $file if your filename has spaces.

Related

Detect command line misentries in Ansible terminal plugin

We've created a custom terminal_plugin for Ansible to be able to support our storage devices. Although it's working as expected for correctly typed commands, it's having issues when a command is being misentered. We would prefer to handle command line misentries as errors, because the storage device will start the new prompt with the misentered command.
We're currently using the following regular expressions as terminal_stdout_re and terminal_stderr_re:
terminal_stdout_re = [
re.compile(br"[\r\n]?.+>(?:\s*)$"),
re.compile(br"[\r\n]?.+>(?:\s*.*)$"),
]
terminal_stderr_re = [
re.compile(br"\^"),
re.compile(br"error:", re.I),
]
Example of a command line misentry on the storage device:
admin:/>add part
^
port port_group
admin:/>add part
Even though we've included the \^ expression in the terminal_stderr_re list, it's not detecting the command line misentry as an error. Any idea what's going wrong?

How to pass command line arguments to Deno?

I have a Deno app, that I wish to pass some command line args to. I searched the manual, but found nothing.
I tried to use the same commands used in Node.js, assuming they might be sharing some for the std libraries, but it didn't work as well.
var args = process.argv.slice(2);
// Uncaught ReferenceError: process is not defined
Any suggestions?
You can access arguments by using Deno.args, it will contain an array of the arguments passed to that script.
// deno run args.js one two three
console.log(Deno.args); // ['one, 'two', 'three']
If you want to parse those arguments you can use std/flags, which will parse the arguments similar to minimist
import { parse } from "https://deno.land/std/flags/mod.ts";
console.log(parse(Deno.args))
If you call it with:
deno run args.js -h 1 -w on
You'll get
{ _: [], h: 1, w: "on" }
You can use Deno.args to access the command line arguments in Deno.
To try it create a file test.ts :
console.log(Deno.args);
And run it with deno run test.ts firstArgument secondArgument
It will return you with an array of the passed args:
$ deno run test.ts firstArgument secondArgument
[ "firstArgument", "secondArgument" ]
If you take a stroll through the standard library, you will find a library named flags, which sounds like it could be library for command line parsing. In the README, you will find your answer in the very first line:
const { args } = Deno;
Also, if you look at the Deno Manual, specifically the Examples section, you will find numerous examples of command line example programs that perform argument parsing, for example, a clone of the Unix cat command (which is also included in the First Steps section of the Deno Manual), where you will also find your answer in the first line:
for (let i = 0; i < Deno.args.length; i++)
So, in short: the command line arguments are a property of the global Deno object, which is documented here:
const Deno.args: string[]
Returns the script arguments to the program. If for example we run a program:
deno run --allow-read https://deno.land/std/examples/cat.ts /etc/passwd
Then Deno.args will contain:
[ "/etc/passwd" ]
Note: According to the Manual, all non-web APIs are under the global Deno namespace.

How to pass "args" while using Intellij IDEA [example list 3.11 in Odersky's Scala book (2nd Ed)]

I basically try to run the example 3.11 in Odersky's book (Programming in Scala). I am using Intellij IDE. While runing the code, the "else" branch got executed.
The screen capture is here:
The source is here in case you need it to try:
package ch3
import scala.io.Source
object l3p11 extends App{
def widthOfLength(s: String) = s.length.toString.length
if (args.length > 0){
val lines = Source.fromFile(args(0)).getLines().toList
val longestLine = lines.reduceLeft(
(a, b) => if (a.length > b.length) a else b
)
val maxWidth = widthOfLength(longestLine)
for (line <- lines){
val numSpaces = maxWidth - widthOfLength(line)
val padding = " " * numSpaces
println(padding + line.length + "|" + line)
}
}
else
Console.err.println("Please enter filename")
}
The reason, I think, is becuase I did not pass args correctly (say here I want to pass the source file l3p11.scala as the args). I tried several option, but have not find a way to pass the args correctly for the code to be executed in the "if" branch. There are two directions in my mind to resolve this problem:
1. Find the right way to pass args in Intellij IDE
Run Scala in commond line, a similar command such as
$ scala l3p11.scala l3p11.scala
should be able to pass the args correctly. But my current setting gives "bash: scala: command not found". I currently use scala REPL to run scala code following the set up given in Odersky's Coursera course on Scala. I think I need to change the set up in orde run scala directly, instead of using "sbt->console" to invoke the scala interpreter like what I am doing now.
Any suggestion on either direction (or other directions that I have not thought of) to resolve the problem is welcome.
Update 1:
Direction 2 works after I reinstall scala. (My to be corrected understanding is that the installation of sbt does not provide an executable binary of scala to be included in the environment list for Windows. Therefore, scala command cannot be found before). After installation of scala directly:
$ scala l3p11.scala l3p11.scala
gives the expected results. But I still have not figured out how to get this result with Intellij IDEA.
Update 2:
I revisited the "Program arguments" option after Joe's confirmation. The reason I was not be able to get it work before was that I only add "l3p11.scala". Adding the complete path from working directory "src/main/scala/ch3/l3p11.scala" solved the problem. The result is as following:
To pass command-line arguments when running a program in IntelliJ IDEA, use the "Edit Configurations …" menu item under "Run". Choose the entry for your main program. There's a "Program arguments" text field where you specify the arguments to pass to the program.
I'm not super familiar on how it will run on windows but if you are able to run it directly from the command line then I think you'll need to compile first, that's the scalac command. So:
$ scalac l3p11.scala
then you can run just with the class name, not sure if you would need quotes on the arg:
$ scala l3p11 l3p11.scala

Why do I get 'Can't locate object method "init" via package "wlgmod::odt"' when I try to run wyd.pl in Cygwin?

I'm trying to run a Perl script called WyD using Cygwin on Windows. Cygwin is installed at C:\cygwin64, and WyD is installed at C:\wyd\wyd.pl. Both are in the Windows PATH environment variable as C:\cygwin64 and C:\wyd respectively.
When running WyD with bash/Mintty using:
wyd.pl -b -e -t -s 3 -o "OUTPUTTEDWORDLIST" "TARGETFOLDER"
...I get the following error:
Can't locate object method "init" via package "wlgmod::odt" (perhaps
you forgot to load "wlgmod::odt"?) at /cygdrive/c/WYD/wyd.pl line 284.
Sometimes wlgmod::odt is replaced with wlgmod::doc or any other document type, but running the script always generates that same basic error. A previous answer to this question recommended installing several dependencies, which turned out to be a mere copy-paste of an answer for Ubuntu systems, and didn't solve the error, so I've decided to start at the beginning and re-ask the question with more details. I also have all Perl packages in the Cygwin installer installed.
After everything I've tried and done to get this script working, I can personally think of two possible causes for the error. Think of these as a guide more than anything else.
The error above references line 284 in the wyd.pl script, so it's possible that something in that script is hardcoded so that it doesn't work with Cygwin/Windows, or just generally has a compatibility bug. I don't understand Perl, so I can't confirm this.
I notice that the installation of WyD at C:\wyd contains a folder called wlgmod, and that folder contains all the files that the above error seems to be looking for; doc.pm, html.pm, jpeg.pm, etc. If those files exist in that directory but bash is unable to find them, maybe it's due to the fact WyD needs to be run from within Cygwin itself. I've only recently thought about this possibility, and my knowledge of both Cygwin and WyD is too sparse to definitively know how both work. Is it even possible to run WyD from within the Cygwin folder? It's not a package so can't be installed as one, and therefore I'm not sure how that would work.
Here are the relevant sections of the script:
# Module hash containing module name and supported file extensions
# Multiple extensions are seperated using ';'
my %wlgmods = (
'wlgmod::strings', '', # only used with command-line switch
'wlgmod::plain' , '.txt', # used for all MIME text/plain as well
'wlgmod::html' , '.html;.htm;.php;.php3;.php4',
'wlgmod::doc' , '.doc',
'wlgmod::pdf' , '.pdf',
'wlgmod::mp3' , '.mp3',
'wlgmod::ppt' , '.ppt',
'wlgmod::jpeg' , '.jpeg;.jpg;.JPG;.JPEG',
'wlgmod::odt' , '.odt;.ods;.odp'
);
...
# Initialize possible modules
foreach(keys %wlgmods) {
eval("use $_;");
my $ret = $_->init(); # line 284
# If module failed, add errortext and remove from hash
if($ret) {
$retvals .= "$_: $ret\n";
delete $wlgmods{$_};
$ret = "";
}
}

Missing local commands after running zopeskel on windows

I try to create an archetype with zopskel/paster on my newly installed plone 4.2. I have adjusted the buildout.cfg (see below) to get zopeskel.exe and paster.exe generated in the bin folder.
Howerver when I run zopeskel as follows (in develop-eggs folder):
..\bin\zopeskel.exe archetype
I get an IOError (see below for output)
From what I understand I should now have local commands when running paster (like add). However when I now run paster (in the develop-eggs/nortek.test03) folder there is no commands.
Is there a bug/flaw in the zopeskel or am I doing something wrong? How do I proceed?
Traceback (most recent call last):
File "C:\Plone42\bin\zopeskel-script.py", line 16, in <module>
zopeskel.zopeskel_script.run()
File "c:\plone42\eggs\zopeskel-2.21.2-py2.6.egg\zopeskel\zopeskel_script.py", line 397, in run
command.run( [ '-q', '-t', template_name ] + optslist )
File "c:\plone42\eggs\pastescript-1.7.5-py2.6.egg\paste\script\command.py", line 238, in run
result = self.command()
File "c:\plone42\eggs\pastescript-1.7.5-py2.6.egg\paste\script\create_distro.py", line 170, in command
egg_info_dir = pluginlib.egg_info_dir(output_dir, dist_name)
File "c:\plone42\eggs\pastescript-1.7.5-py2.6.egg\paste\script\pluginlib.py", line 135, in egg_info_dir
% ', '.join(all))
IOError: No egg-info directory found (looked in .\nortek.test03\.\nortek.test03.egg-info, .\nortek.test03\CHAN
GES.txt\nortek.test03.egg-info, .\nortek.test03\CONTRIBUTORS.txt\nortek.test03.egg-info, .\nortek.test03\docs\
nortek.test03.egg-info, .\nortek.test03\MANIFEST.in\nortek.test03.egg-info, .\nortek.test03\nortek\nortek.test
03.egg-info, .\nortek.test03\README.txt\nortek.test03.egg-info, .\nortek.test03\setup.cfg\nortek.test03.egg-in
fo, .\nortek.test03\setup.py\nortek.test03.egg-info)
My buildout.cfg is identical to default except the following:
parts =
zeo
instance
run-instance
run-zeo
service
service-zeo
zopeskel
[zopeskel]
recipe = zc.recipe.egg
unzip = true
eggs =
Paste
PasteScript
ZopeSkel
[EDIT]
I tried to follow the instructions in the link provided. However there are several problems that occure:
* no paste script is generated in bin folder
* I still get exactly the same IOError issue
* There are no local commands
I put output from the different commands I ran onto this link:
http://pastie.org/4664202
So please help me as I still have the same problem
Please use the upgraded instructions:
http://collective-docs.readthedocs.org/en/latest/getstarted/paste.html
Wherever you found those instructions please tell it to us and we will try take down the bad instructions.

Resources