This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
drop table if exists #t | |
create table #t ( | |
RowId int primary key identity(1,1) | |
,Col1 int | |
,BatchId smallint | |
) | |
insert into #t (Col1) | |
values | |
(1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
qemu-img convert -f vdi -O qcow2 WorkWindowsServer2022.vdi WorkWindowsServer2022.qcow2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@staticmethod | |
def encodingDetect(s): | |
import chardet | |
try: | |
return chardet.detect(s) | |
except UnicodeDecodeError: | |
return chardet.detect(s.encode('utf-8')) | |
@staticmethod | |
def encodingConvertUnicode(s): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@staticmethod | |
def get_public_ip(): | |
import requests | |
from Validator import Validator | |
IP_URL = 'http://checkip.amazonaws.com/' | |
try: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@staticmethod | |
def get_unique_filename(filepath: str): | |
if StringUtil.isNullOrEmpty(filepath): | |
return | |
import os | |
filepath = os.path.getabspath(filepath) | |
if os.path.exists(filepath): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@staticmethod | |
def get_files_recursively(directory: str, file_extensions: ()): | |
if not directory or not file_extensions: | |
return | |
matched_files = [] # files that have matching extension | |
directory = os.path.abspath(directory) | |
fileslist = os.listdir(directory) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@staticmethod | |
def enumerate_files_from_paths(paths): | |
""" | |
Description: | |
Returns list of all files from a list of paths | |
:param paths: tuple | |
List of all paths to enumerate | |
:return: | |
""" | |
try: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@staticmethod | |
def calc_crc32(file_path: str): | |
if not file_path: | |
return | |
import binascii | |
with open(file_path, 'rb') as f: | |
buf = f.read() | |
buf = (binascii.crc32(buf) & 0xFFFFFFFF) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@staticmethod | |
def backup_file(filename: str, backupname: str = None): | |
""" | |
Pass in filename/path to create a backup | |
Ensures the name for the backup is unique, whehter it is specifically given or not | |
:param filename: str | |
Name of file or path to the file | |
If os.path.isfile(filename) returns False, it raises an IOException | |
:param backupname: | |
Optional |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hashlib | |
def md5sum(filename): | |
if not filename or not os.path.isfile(filename): | |
return | |
hash_md5 = hashlib.md5() | |
with open(filename, "rb") as f: | |
for chunk in iter(lambda: f.read(8192), b""): | |
hash_md5.update(chunk) |
NewerOlder