Webdriver:在将文件名保存到文件夹之前更改文件名

时间:2019-03-07 03:49:37

标签: python webdriver nas

当我使用webdriver浏览网站时,它将自动将文件下载到我的文件夹中,但是文件名为“ Bike.gz”,可以在之前将其名称更改为“ {current time} .txt”保存到我的文件夹?例如,为“ 2019-03-07-11-46.txt”。

代码:

<template>
  <div>
    <v-card v-show="createProducts">
      <v-toolbar card prominent color="primary" dark>
        <v-toolbar-title>Create Product</v-toolbar-title>
      </v-toolbar>
      <v-card-text>
        {{ product }}
        <v-form ref="form" v-model="valid" lazy-validation>
          <v-container>
            <v-layout row wrap>
          <v-flex xs6>
          <v-text-field
            v-model="product.name"
            label="Product Name"
            v-validate="'required'"
            required
            solo=""
            data-vv-name="product name"
            :error-messages="errors.collect('product name')"
          ></v-text-field>
          </v-flex>

          <v-flex xs6>
          <v-text-field
            v-model="product.code"
            label="Product Code"
            v-validate="'required'"
            required
            solo=""
            data-vv-name="product code"
            :error-messages="errors.collect('product code')"
          ></v-text-field>
          </v-flex>

          <v-flex xs12>
          <v-textarea
            v-model="product.description"
            :auto-grow="true"
            :box="false"
            solo
            :autofocus= "true"
            :outline="false"
            color="black"
            background-color="white"
            label="Product Description"
            rows="3"
          ></v-textarea>
          </v-flex>

         
          <v-flex xs12>
          <v-select
            :items="dashboard"
            label="Dashboard Template"
            v-model="product.dashbaord"
            data-vv-name="dashboard"
            v-validate="'required'"
            required
            solo=""
            :error-messages="errors.collect('template')"
          ></v-select>
          </v-flex>

          <!-- dialog box -->

    <v-dialog  v-model="dialog" width="500">
      <v-btn slot="activator" color="primary" @click="createNewProduct" center>Save</v-btn>
        <v-card>
          <v-card-title class="headline grey lighten-2" primary-title>Error</v-card-title>

          <v-card-text>Product Code already exists</v-card-text>

          <v-divider></v-divider>

          <v-card-actions>
            <v-spacer></v-spacer>
           <v-btn color="blue darken-1" flat @click="dialog= false">No</v-btn>
          </v-card-actions>
        </v-card>
      </v-dialog>


            </v-layout>
          </v-container>
        </v-form>
      </v-card-text>
    </v-card>
  </div>
</template>

<script>
import RestResource from "../services/dataService.js";
const service = new RestResource();

export default {
  name: "createProducts",
  data() {
    return {
      createProducts: true,
      valid: true,
      product: {},
      dialog: false,
      dashboard: [
        "Template1",
        "Template2",
        "Template3",
        "Template4",
        "Template5",
        "Template6"
      ]
     
    }
    
  },

  methods: {
    async createNewProduct() {
      let v = await this.$validator.validateAll();
      console.log(`validation :: ${v}`)

      if (v) {
      
      let a = await service.createProduct(this.product).then(r => {
      alert("Done..." + r);
        
      }).catch (e => {
        alert("Failed..." + e);
        
      })
      // this.$router.push({ name: "products"});    
      }
    }
  },


};
</script>

此外,“ \ xxx.xx.xxx.xx \ bike_test”是我的NAS路径,如果我在AWS上运行它,如何下载文件并将其直接保存到我的NAS文件夹 bike_test >?还是我必须先将其保存在我的AWS文件夹中,然后进行转换?

0 个答案:

没有答案