How to use from_file method in autotest

Best Python code snippet using autotest_python

samples.py

Source:samples.py Github

copy

Full Screen

1from pydub import AudioSegment2crash = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\drums\\crash.wav")3ride = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\drums\\ride.wav")4hi_hat = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\drums\\hi_hat.wav")5snare = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\drums\\snare.wav")6tom1 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\drums\\tom1.wav")7tom2 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\drums\\tom2.wav")8tom3 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\drums\\tom3.wav")9bass = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\drums\\bass.wav")10hi_hat_foot = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\drums\\hi_hat_foot.wav")11bA1 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bA1.wav")12bB1 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bB1.wav")13bC1 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bC1.wav")14bD1 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bD1.wav")15bE1 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bE1.wav")16bF1 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bF1.wav")17bG1 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bG1.wav")18bA2 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bA2.wav")19bB2 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bB2.wav")20bC2 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bC2.wav")21bD2 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bD2.wav")22bE2 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bE2.wav")23bF2 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bF2.wav")24bG2 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bG2.wav")25bA3 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bA3.wav")26bB3 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bB3.wav")27bC3 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bC3.wav")28bD3 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bD3.wav")29bE3 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bE3.wav")30bF3 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bF3.wav")31bG3 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bG3.wav")32bA4 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bA4.wav")33bB4 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bB4.wav")34bC4 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bC4.wav")35bD4 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bD4.wav")36bE4 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bE4.wav")37bF4 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bF4.wav")38bG4 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bG4.wav")39bA5 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bA5.wav")40bB5 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bB5.wav")41bC5 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bC5.wav")42bD5 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bD5.wav")43bE5 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bE5.wav")44bF5 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bF5.wav")45bG5 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bG5.wav")46bA6 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bA6.wav")47bB6 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bB6.wav")48bC6 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bC6.wav")49bD6 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bD6.wav")50bE6 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bE6.wav")51bF6 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bF6.wav")52bG6 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bG6.wav")53bA7 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bA7.wav")54bB7 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bB7.wav")55bC7 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bC7.wav")56bD7 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bD7.wav")57bE7 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bE7.wav")58bF7 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bF7.wav")59bG7 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bG7.wav")60bA8 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bA8.wav")61bB8 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bB8.wav")62bC8 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bC8.wav")63bD8 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bD8.wav")64bE8 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bE8.wav")65bF8 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bF8.wav")66bG8 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\bass\\bG8.wav")67aA1 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aA1.wav")68aB1 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aB1.wav")69aC1 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aC1.wav")70aD1 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aD1.wav")71aE1 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aE1.wav")72aF1 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aF1.wav")73aG1 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aG1.wav")74aA2 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aA2.wav")75aB2 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aB2.wav")76aC2 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aC2.wav")77aD2 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aD2.wav")78aE2 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aE2.wav")79aF2 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aF2.wav")80aG2 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aG2.wav")81aA3 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aA3.wav")82aB3 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aB3.wav")83aC3 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aC3.wav")84aD3 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aD3.wav")85aE3 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aE3.wav")86aF3 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aF3.wav")87aG3 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aG3.wav")88aA4 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aA4.wav")89aB4 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aB4.wav")90aC4 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aC4.wav")91aD4 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aD4.wav")92aE4 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aE4.wav")93aF4 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aF4.wav")94aG4 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aG4.wav")95aA5 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aA5.wav")96aB5 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aB5.wav")97aC5 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aC5.wav")98aD5 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aD5.wav")99aE5 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aE5.wav")100aF5 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aF5.wav")101aG5 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aG5.wav")102aA6 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aA6.wav")103aB6 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aB6.wav")104aC6 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aC6.wav")105aD6 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aD6.wav")106aE6 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aE6.wav")107aF6 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aF6.wav")108aG6 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aG6.wav")109aA7 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aA7.wav")110aB7 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aB7.wav")111aC7 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aC7.wav")112aD7 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aD7.wav")113aE7 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aE7.wav")114aF7 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aF7.wav")115aG7 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aG7.wav")116aA8 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aA8.wav")117aB8 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aB8.wav")118aC8 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aC8.wav")119aD8 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aD8.wav")120aE8 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aE8.wav")121aF8 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aF8.wav")122aG8 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\aG8.wav")123eA1 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eA1.wav")124eB1 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eB1.wav")125eC1 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eC1.wav")126eD1 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eD1.wav")127eE1 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eE1.wav")128eF1 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eF1.wav")129eG1 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eG1.wav")130eA2 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eA2.wav")131eB2 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eB2.wav")132eC2 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eC2.wav")133eD2 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eD2.wav")134eE2 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eE2.wav")135eF2 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eF2.wav")136eG2 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eG2.wav")137eA3 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eA3.wav")138eB3 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eB3.wav")139eC3 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eC3.wav")140eD3 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eD3.wav")141eE3 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eE3.wav")142eF3 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eF3.wav")143eG3 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eG3.wav")144eA4 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eA4.wav")145eB4 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eB4.wav")146eC4 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eC4.wav")147eD4 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eD4.wav")148eE4 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eE4.wav")149eF4 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eF4.wav")150eG4 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eG4.wav")151eA5 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eA5.wav")152eB5 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eB5.wav")153eC5 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eC5.wav")154eD5 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eD5.wav")155eE5 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eE5.wav")156eF5 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eF5.wav")157eG5 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eG5.wav")158eA6 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eA6.wav")159eB6 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eB6.wav")160eC6 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eC6.wav")161eD6 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eD6.wav")162eE6 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eE6.wav")163eF6 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eF6.wav")164eG6 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eG6.wav")165eA7 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eA7.wav")166eB7 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eB7.wav")167eC7 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eC7.wav")168eD7 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eD7.wav")169eE7 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eE7.wav")170eF7 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eF7.wav")171eG7 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eG7.wav")172eA8 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eA8.wav")173eB8 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eB8.wav")174eC8 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eC8.wav")175eD8 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eD8.wav")176eE8 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eE8.wav")177eF8 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eF8.wav")178eG8 = AudioSegment.from_file("\\Cyber 12th grade\\Project\\samples\\guitar\\eG8.wav")...

Full Screen

Full Screen

file_transfer.py

Source:file_transfer.py Github

copy

Full Screen

1from typing import Optional, Union2from .enums import FileTransferStrategyTypes, FtCallDepReturnValue, Order3from .file import File4from .strategies.http_strategy import HTTP5from .strategies.rsync_strategy import Rsync6from .strategies.transfer_strategy_base import FileTransferStrategy7class FileTransfer:8 """9 FileTransfer object class that takes two File objects or filepaths (from, to) and a File Transfer Strategy to perform remote or local file transfer operations.10 Attributes:11 from_file: Filepath or File object corresponding to the source file.12 to_file: Filepath or File object corresponding to the destination file.13 order: Order (enum) to execute the file transfer before (Order.BEFORE) or after (Order.AFTER) electron execution.14 strategy: Optional File Transfer Strategy to perform file operations - default will be resolved from provided file schemes.15 """16 def __init__(17 self,18 from_file: Optional[Union[File, str]] = None,19 to_file: Optional[Union[File, str]] = None,20 order: Order = Order.BEFORE,21 strategy: Optional[FileTransferStrategy] = None,22 ) -> None:23 if isinstance(from_file, str) or from_file is None:24 from_file = File(from_file)25 elif not isinstance(from_file, File):26 raise AttributeError(27 "FileTransfer() requires files to be either of type File, string, or None."28 )29 if isinstance(to_file, str) or to_file is None:30 to_file = File(to_file)31 elif not isinstance(to_file, File):32 raise AttributeError(33 "FileTransfer requires files to be either of type File, string, or None."34 )35 # assign explicit strategy or default to strategy based on from_file & to_file schemes36 if strategy:37 self.strategy = strategy38 elif (39 from_file.mapped_strategy_type == FileTransferStrategyTypes.Rsync40 and to_file.mapped_strategy_type == FileTransferStrategyTypes.Rsync41 ):42 self.strategy = Rsync()43 elif from_file.mapped_strategy_type == FileTransferStrategyTypes.HTTP:44 self.strategy = HTTP()45 else:46 raise AttributeError("FileTransfer requires a file transfer strategy to be specified")47 self.to_file = to_file48 self.from_file = from_file49 self.order = order50 # this is currently the case but as we further develop file transfer strategies we may support this51 # for example we may support streaming files between buckets in S352 if self.from_file.is_remote and self.to_file.is_remote:53 raise ValueError(54 "FileTransfer currently does not support remote->remote file transfers, please update from_filepath or to_filepath to correspond to a local filepath."55 )56 def cp(self):57 file_transfer_call_dep = None58 return_value_type = FtCallDepReturnValue.FROM_TO59 # local -> local or remote -> remote60 if (not self.from_file.is_remote and not self.to_file.is_remote) or (61 self.from_file.is_remote and self.to_file.is_remote62 ):63 file_transfer_call_dep = self.strategy.cp(self.from_file, self.to_file)64 # local -> remote65 if not self.from_file.is_remote and self.to_file.is_remote:66 file_transfer_call_dep = self.strategy.upload(self.from_file, self.to_file)67 # remote -> local68 if self.from_file.is_remote and not self.to_file.is_remote:69 file_transfer_call_dep = self.strategy.download(self.from_file, self.to_file)70 pre_transfer_hook_call_dep = self.strategy.pre_transfer_hook(71 self.from_file, self.to_file, return_value_type=return_value_type72 )73 return (pre_transfer_hook_call_dep, file_transfer_call_dep)74# Factories75def TransferFromRemote(76 from_filepath: str,77 to_filepath: Union[str, None] = None,78 strategy: Optional[FileTransferStrategy] = None,79 order: Order = Order.BEFORE,80) -> FileTransfer:81 """82 Factory for creating a FileTransfer instance where from_filepath is implicitly created as a remote File Object, and the order (Order.BEFORE) is set so that this file transfer will occur prior to electron execution.83 Args:84 from_filepath: File path corresponding to remote file (source).85 to_filepath: File path corresponding to local file (destination)86 strategy: Optional File Transfer Strategy to perform file operations - default will be resolved from provided file schemes.87 order: Order (enum) to execute the file transfer before (Order.BEFORE) or after (Order.AFTER) electron execution - default is BEFORE88 Returns:89 FileTransfer instance with implicit Order.BEFORE enum set and from (source) file marked as remote90 """91 # override is_remote for the case where from_filepath is of a file:// scheme where the file is remote (rsync ssh)92 from_file = File(from_filepath, is_remote=True)93 return FileTransfer(94 from_file=from_file, to_file=to_filepath, order=Order.BEFORE, strategy=strategy95 )96def TransferToRemote(97 to_filepath: str,98 from_filepath: Union[str, None] = None,99 strategy: Optional[FileTransferStrategy] = None,100 order: Order = Order.AFTER,101) -> FileTransfer:102 """103 Factory for creating a FileTransfer instance where to_filepath is implicitly created as a remote File Object, and the order (Order.AFTER) is set so that this file transfer will occur post electron execution.104 Args:105 to_filepath: File path corresponding to remote file (destination)106 from_filepath: File path corresponding to local file (source).107 strategy: Optional File Transfer Strategy to perform file operations - default will be resolved from provided file schemes.108 order: Order (enum) to execute the file transfer before (Order.BEFORE) or after (Order.AFTER) electron execution - default is AFTER109 Returns:110 FileTransfer instance with implicit Order.AFTER enum set and to (destination) file marked as remote111 """112 # override is_remote for the case where to_filepath is of a file:// scheme where the file is remote (rsync ssh)113 to_file = File(to_filepath, is_remote=True)114 return FileTransfer(115 from_file=from_filepath, to_file=to_file, order=Order.AFTER, strategy=strategy...

Full Screen

Full Screen

PreTrain_2.py

Source:PreTrain_2.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2nums = 1003import codecs4import os5import shutil6from os.path import join, getsize7import imghdr8from PIL import Image9from PIL import ImageFile10ImageFile.LOAD_TRUNCATED_IMAGES = True11train_num = 320012test_num = 16013pathName = '/home/ylj/tag_sys/GrapImage/TRAINS_bak/'14# disPathName = '/home/ylj/tag_sys/GrapImage/new_data_train/'15#16# train_dir = os.path.join(disPathName, 'train')17# validation_dir = os.path.join(disPathName, 'validation')18# test_dir = os.path.join(disPathName, 'test')19# if not os.path.exists(train_dir):20# os.makedirs(train_dir)21#22# if not os.path.exists(validation_dir):23# os.makedirs(validation_dir)24#25# if not os.path.exists(test_dir):26# os.makedirs(test_dir)27#28for dir_path, dir_names, file_names in os.walk(pathName):29 fileNums = len(file_names)30 # if fileNums > 640:31 # print dir_path, fileNums32 if(fileNums > (train_num + test_num)):33 print dir_path, fileNums34 # 删除类型为None文件35 for i in range(fileNums):36 from_file = os.path.join(dir_path, file_names[i])37 pic_type = imghdr.what(from_file)38 if pic_type == 'jpeg':39 pass40 # print from_file, pic_type41 elif pic_type == 'gif':42 # s = from_file.split('.')43 # os.rename(from_file, s[-2] + ".gif")44 # print s[-2] + ".gif", pic_type45 # print from_file, pic_type46 print from_file, pic_type, '删除'47 os.unlink(from_file)48 elif pic_type == 'png':49 # s = from_file.split('.')50 # os.rename(from_file, s[-2] + ".png")51 # print s[-2] + ".png", pic_type52 # print from_file, pic_type53 print from_file, pic_type, '删除'54 os.unlink(from_file)55 else:56 print from_file, pic_type, '删除'57 os.unlink(from_file)58 # print from_file, pic_type59 # image = Image.open(from_file)60 # try:61 # image = Image.open(from_file)62 # # print image63 # print from_file64 # except IOError, e:65 # print e66 #67 # except Exception, e:68 # print from_file69 # os.unlink(from_file)70 # # print e71 # #测试训练集72 # for i in range(fileNums):73 # p = dir_path.split('/')[-1]74 # #复制进入训练集75 # if i < train_num:76 # d_p = os.path.join(train_dir, p)77 # if not os.path.exists(d_p):78 # os.makedirs(d_p)79 # elif i < train_num + test_num:80 # d_p = os.path.join(validation_dir, p )81 # if not os.path.exists(d_p):82 # os.makedirs(d_p)83 # else:84 # d_p = os.path.join(test_dir, p)85 # if not os.path.exists(d_p):86 # os.makedirs(d_p)87 # # print i, d_p88 # from_file = os.path.join(dir_path, file_names[i])89 # if(getsize(from_file) < 100):90 # print from_file, getsize(from_file)91 # to_file = os.path.join(d_p, file_names[i])92 # print from_file, to_file93 #94 # # shutil.copy(from_file, to_file)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful