command

What does the `as` command do in Python 3.x?

人盡茶涼 提交于 2019-11-30 20:50:34
问题 I've seen it many times but never understood what the as command does in Python 3.x. Can you explain it in plain English? 回答1: It's not a command per se, it's a keyword used as part of the with statement: with open("myfile.txt") as f: text = f.read() The object after as gets assigned the result of the expression handled by the with context manager. Another use is to rename an imported module: import numpy as np so you can use the name np instead of numpy from now on. The third use is to give

How do I execute Bash commands and collect the output from Java?

半腔热情 提交于 2019-11-30 20:08:45
How do I execute Bash commands and collect the output from Java? Hi all, basically I am writing a basic console app, and would like to be able to run commands from it, such as sudo***, halt, ifconfig, etc. Any insight?. You can use processBuilder API for this purpose. See this example . untested code: Runtime run = Runtime.getRuntime(); Process pr = run.exec(bashcommand); pr.waitFor(); BufferedReader buf = new BufferedReader(new InputStreamReader(pr.getInputStream())); while ( ( String line ; line = buf.readLine() ) != null ) { System.out.println(line); } 来源: https://stackoverflow.com

How can I avoid command clutter in the ViewModel?

天涯浪子 提交于 2019-11-30 19:38:04
I am building an application that uses quite a few commands, and they are cluttering up my viewmodel. MVVM is new to me, so sorry if this question is a bit stupid. Is there a way to reduce the clutter? For example here you can see the a part of the clutter.. private void InitializeCommands() { LogoutCommand = new RelayCommand(Logout); OpenCommand = new RelayCommand(SetImage); SaveCommand = new RelayCommand(SaveImage, SaveImageCanExecute); UploadToFlickrCommand = new RelayCommand(UploadToFlickr); CropCommand = new RelayCommand(SetCropMouseEvents); RemoveRedEyeCommand = new RelayCommand

How do I send commands to an EXE running through the command line with batch?

拜拜、爱过 提交于 2019-11-30 19:15:40
问题 I have a server application running called TerrariaServer.exe and I want to be able to send it commands with separate batch file. TerrariaServer.exe is a program running as a command line. How could I "feed" it a command such as "save" and "exit"? The answer might be pipes, but I'm not too sure. Here is kinda what I executed in a batch file while TerrariaServer.exe was running... @echo off echo save | TerrariaServer.exe echo exit | TerrariaServer.exe After that, nothing happen. I don't know

Multiple layers of Application Data folders - Windows7

社会主义新天地 提交于 2019-11-30 17:59:43
问题 In a command window If I navigate to c:\users\me and do "dir", I see 13 folders but no files. If I do "dir /s", I see thousands of files, but what bothers me is that I see paths like this: C:\Users\me\AppData\Local\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data... then, finally, something like Microsoft\VisualStudio or Google\Chrome or so on. What is it with the layers and layers of Application Data folders? If I search using AgentRansack

“source” command on mac

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-30 17:44:18
问题 I have a .bashrc file on Mac OS in which I set some aliases. After I make it and I type source .bashrc , the aliases work perfectly. However if open another shell, my shortcut command will not be recognized and I need to do source .bashrc again. How can it make it once and for all? 回答1: Terminal and iTerm 2 open new shells as login shells by default. When Bash is opened as a login shell, it reads ~/.bash_profile but not ~/.bashrc . See https://www.gnu.org/software/bash/manual/html_node/Bash

Running a bash command via CMake

天大地大妈咪最大 提交于 2019-11-30 17:29:06
I'm trying to have CMake either run three bash commands or a bash script. However, I can't seem to get it to work. The bash commands are: cd ${CMAKE_SOURCE_DIR}/dependencies/library make cd ${CMAKE_BINARY_DIR} Essentially, I would like CMake to build the library in that directory if it does not already exist. Here's the CMake code I tried: if(NOT "${CMAKE_SOURCE_DIR}/dependencies/library/lib.o") execute_process(COMMAND cd ${CMAKE_SOURCE_DIR}/dependencies/library) execute_process(COMMAND make) execute_process(COMMAND cd ${CMAKE_BINARY_DIR}) endif(NOT "${CMAKE_SOURCE_DIR}/dependencies/library

Grey out image on button when element is disabled (simple and beautiful way)

大憨熊 提交于 2019-11-30 17:10:34
I want to grey out my images (on the buttons) when the buttons are disabled. When I have text (no images) on the button, the text is greyed out (With Images as Button Content they are not grey out). Is there any simple and beautiful way to do that? This is my xaml file: <Window x:Class="WpfApplication2.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="*"/> </Grid.RowDefinitions>

Open file from complete path under cursor in Vim

﹥>﹥吖頭↗ 提交于 2019-11-30 14:36:39
If I have a file that contains a complete path for a file, is there a way to highlight the filename (using visual mode) and open the file (preferably in a split screen)? Here is the behavior I would like: if the file name contains a / character, assume it is a full path (i.e. the current directory is root). Otherwise, use the current folder (i.e. default behavior). Is this possible? catchmeifyoutry Put the cursor on the filename and type gf (in command mode). Or use CTRL + W | CTRL + F to open in another window. See also :help gf (no, it's not your girlfriend). gf command opens file under

Batch file 'choice' command's errorlevel returns 0

大憨熊 提交于 2019-11-30 14:20:47
I'm trying to create a batch file that performs different 'choice' command based on the version of Windows being executed on. The choice command's syntax is different between Windows 7 and Windows XP. Choice command returns a 1 for Y and 2 for N. The following command returns the correct error level: Windows 7: choice /t 5 /d Y /m "Do you want to automatically shutdown the computer afterwards " echo %errorlevel% if '%errorlevel%'=='1' set Shutdown=T if '%errorlevel%'=='2' set Shutdown=F Windows XP: choice /t:Y,5 "Do you want to automatically shutdown the computer afterwards " echo %ERRORLEVEL%