标签名称为Ansible的EC2实例的动态脚本清单(基于其值)

时间:2019-04-06 19:20:17

标签: python boto3

我正在尝试使用Boto3函数编写示例python代码,以检查具有标签名称'Ansible'及其值'DB'或'APP'的Ec2实例,它应返回这些标签值的各自私有IP地址。 / p>

试图通过添加[]来更改过滤器。 在我在youtube链接中找到的代码中,即使添加了[]也没有[],但我收到此错误。

import { app, BrowserWindow, ipcMain } from 'electron';
import installExtension, { REACT_DEVELOPER_TOOLS } from 'electron-devtools-installer';
import { enableLiveReload } from 'electron-compile';

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow;
let previewWindow;

const isDevMode = process.execPath.match(/[\\/]electron/);

if (isDevMode) enableLiveReload({ strategy: 'react-hmr' });

const createWindow = async () => {
  // Create the browser window.
  mainWindow = new BrowserWindow({
    width: 400,
    height: 650,
    minWidth: 400,
    minHeight: 650,
    maxHeight: 650,
    maxWidth: 400,
    frame: false
  });

  // and load the index.html of the app.
  mainWindow.loadURL(`file://${__dirname}/index.html`);

  // Open the DevTools.
  if (isDevMode) {
    await installExtension(REACT_DEVELOPER_TOOLS);
    mainWindow.webContents.openDevTools();
  }

  // Emitted when the window is closed.
  mainWindow.on('closed', () => {
    // Dereference the window object, usually you would store windows
    // in an array if your app supports multi windows, this is the time
    // when you should delete the corresponding element.
    mainWindow = null;
  });

  ipcMain.on('close-app', (evt, arg) => {
    mainWindow = null;
    previewWindow = null;
    app.quit();
  })

  ipcMain.on("open-preview", (evt, data) => {

    const mainWinPos = mainWindow.getPosition();

    const width = data.info.width;
    const height = data.info.height + 56;

    previewWindow = new BrowserWindow({
      width: width,
      height: height,
      minWidth: width,
      minHeight: height,
      maxHeight: height,
      maxWidth: width,
      frame: false,
      parent: mainWindow
    });

    previewWindow.setPosition(mainWinPos[0] - (width + 20), mainWinPos[1], false);

    previewWindow.loadURL(`file://${__dirname}/preview.html`);

    previewWindow.webContents.once('did-finish-load', () => {
      previewWindow.webContents.openDevTools();
      previewWindow.webContents.send('render-spritesheets', data);
    });

    previewWindow.on("closed", () => previewWindow = null);
    ipcMain.on("close-preview", () => {
      if (previewWindow) previewWindow.close();
    });


  });


};

// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow);

// Quit when all windows are closed.
app.on('window-all-closed', () => {
  // On OS X it is common for applications and their menu bar
  // to stay active until the user quits explicitly with Cmd + Q
  if (process.platform !== 'darwin') {
    app.quit();
  }
});

app.on('activate', () => {
  // On OS X it's common to re-create a window in the app when the
  // dock icon is clicked and there are no other windows open.
  if (mainWindow === null) {
    createWindow();
  }
});

// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and import them here.

例如,我有4个标签名称为Ansible的实例,其中值'db'为2个实例,'app'为另外2个实例。 我的输出应该像 分贝[172.31.24.232,172.31.21.244] 应用[172.31.30.42,172.31.26.116]

1 个答案:

答案 0 :(得分:0)

doC()