Package: shaonutil
Shaonutil  - 0.0.0.61.1Utility Functions for DevelopersStable Version - 0.0.0.61.1Author: Shaon MajumderContact:smazoomder@gmail.comArea of UtilitiesfileimageimgcodemysqlDBnetworkprocesssecuritystatsstringswindowsInstallationpip install shaonutilFunction UsagesFileFunctionget_module_path(module)Functionget_all_dirs()Functionget_all_files_dirs()Functionpackage_exists(package_name)-> Description: check if a python pcakage exists.Functionpip_install(package_name)Functionget_all_functions(object)-> Description: shaonutil.file.get_all_functions(object/file/class)FunctionConfigSectionMap(Config,section)Functionread_configuration_ini(filename)Functionread_safecase_configuration_ini(filename)Functionwrite_configuration_ini(configs_par,filename,f_mode)Functionread_json(filename)-> Description: Read JSON file and return dictionaryFunctionwrite_json(obj,filename)-> Description: Write JSON fileFunctionread_file(filename)-> Description: Read File and return lines as listFunctionwrite_file(filename,strs,mode)-> Description: Write File from stringFunctionread_pickle(filename)Functionwrite_pickle(filename,obj_)Functionopen_file_with_default_app(filepath)Functionget_last_file_of_dir(filename)Functionremove_duplicateLines_from_file(filename)ClassCaseConfigParserFunctionoptionxform(optionstr)ImageFunctionsvg2img(infile,outfile)Functionsvg2pdf(infile,outfile)Functionchange_image_size_ratio(img_name,out_name,percent)Functiondraw_text(img,text,fnt_name,fnt_size)Functionmerge_horizontally(images,filename)Functionmerge_vertically(images,filename)Functiongive_screenshot_caption(img_name,text,fnt_path)BarCodeFunctioncalculate_checksum(data)-> Description: Calculates the checksum for EAN13-Code / EAN8-Code return type: IntegerFunctionverify_data(data)-> Description: Verify the EAN encoded dataFunctionactual_data(decodedObjects)-> Description: Returns data without checksum digit for EAN typeFunctionencode(type_,file_,data,rt)-> Description: Encode the data as barcode or qrcodeFunctiondecode(infile,log)-> Description: Decode barcode or qrcodeFunctionmarkBarcode(im,decodedObjects)-> Description: Mark and show the detected barcodeFunctionmake_barcode_matrix(type_,unique_ids,row_number,column_number,filename)-> Description: Make barcode matrix imageFunctionread_live_barcode(detection_threshold)-> Description: Live read the barcode and returns dataMysql DatabaseFunctioncreate_configuration(option,file_name)-> Description: Creating ConfigurationFunctionremove_aria_log(mysql_data_dir)-> Description: Removing aria_log.### files to in mysql data dir to restart mysqlFunctionget_mysql_datadir(mysql_bin_folder,user,pass_)-> Description: Get mysql data directoryClassMySQL-> Description: A class for all mysql actionsFunctioninit(config,init_start_server,log)Functionstart_mysql_server()-> Description: Start mysql serverFunctionstop_mysql_server(force)-> Description: Stop MySQL ServerFunctionreopen_connection()-> Description: reopenFunctionclose_connection()-> Description: closing the connectionFunctionconfig()Functionconfig(new_value)Functionfilter_config()Functionmake_cursor()Functionis_mysql_user_exist(mysql_username)-> Description: check if mysql user exist return type:booleanFunctionlistMySQLUsers()-> Description: list all mysql usersFunctioncreateMySQLUser(host,userName,password,querynum,updatenum,connection_num)-> Description: Create a Mysql UserFunctiondelete_mysql_user(user,host,password)-> Description: Delete a mysql userFunctionshow_privileges(user,host)-> Description: Show privileges of mysql userFunctioncheck_privileges(database,host,username)-> Description: Check if a mysql user has privileges on a databaseFunctiongrant_all_privileges(host,userName,privileges,database,table,querynum,updatenum,connection_num)-> Description: Grant a user all privilagesFunctiongrant_privileges(user,host,database,privileges,table)-> Description: Grant specified privileges for a mysql userFunctionremove_all_privileges(user,host,privileges)-> Description: Revoke/Remove all privileges for a mysql userFunctionremove_privileges(user,host,privileges)-> Description: Remove specified privileges for a mysql userFunctionchange_privileges(user,host,privileges)-> Description: Change to specified privileges for a mysql userFunctionflush_privileges()-> Description: Update database permissions/privilagesFunctionadd_db_privilages_for_MySQLUSer()Functionchange_db_privilages_for_MySQLUSer()Functionis_db_exist(dbname)-> Description: Check if database existFunctioncreate_database(dbname)-> Description: Create DatabaseFunctiondelete_database(dbname)-> Description: Delete DatabaseFunctionget_databases()-> Description: Get databases namesFunctioncreate_table(tbname,column_info)-> Description: Create a table under a databaseFunctiondelete_table(table,database)-> Description: Delete a table under a databaseFunctionget_tables(database)-> Description: Get table namesFunctiondescribe_table(tbname)-> Description: Describe a table structureFunctionis_table_exist(tbname)-> Description: Check if table existFunctionget_columns(tbname)-> Description: Get column names of a tableFunctionupdate_row()Functiondelete_row()-> Description: Delete a row of dataFunctionadd_column(tbname,column_name)Functiondelete_column(tbname,column_name)Functiondelete_unique_column(tbname,column_name)Functionchange_to_unique_column()Functionchange_column()Functionrename_column(tbname,old_column_name,new_column_name)Functionbackup_all()Functionbackup_table()Functionbackup_database()Functionrestore_table()Functionrestore_databalse()Functionload_CSV_into_table()Functionshow_table(tbname)Functionget_unique_id_from_field(field_name,key_length,filters)-> Description: Get a random unique id not registered in a specific fieldFunctiondelete_row(delete_dict)-> Description: Delete a row of dataFunctioninsert_row(value_tupple)-> Description: Insert row of dataNetworkFunctioncheck_port(address,port,log)FunctionurlExist(url)-> Description: Check if the file exist in onlineFunctiondownloadFile(url,filename)-> Description: Donwload a file if error occurs returns falseFunctionurl_encoding_to_utf_8(url)-> Description: url_encoding_to_utf_8(url)Functioncheck_valid_url(url)ClassEmailFunctioninit()Functionauthentication()Functionauthentication(new_value)Functionsend_email(receiver_address,subject,mail_content,attachment_file_link,log)ProcessFunctionis_process_exist(process_name)Functionkill_duplicate_process(process_name,log)-> Description: Kill a process if there is more than one instance is running.FunctionkillProcess_ByAll(PROCNAME)FunctionkillProcess_ByPid(pid)Functionlist_processes(sort,save_file,log)Functioncomputer_idle_mode()Functionobj_details_dump(obj)-> Description: check dumpSecurityFunctionrandomString(stringLength)-> Description: Generate a random string of fixed lengthFunctiongenerateSecureRandomString(stringLength)-> Description: Generate a secure random string of letters, digits and special charactersFunctiongenerateCryptographicallySecureRandomString(stringLength,filters)-> Description: Generate a random string in a UUID fromat which is crytographically secure and randomStatisticsFunctioncounter(li,number)Functionoccurance_dic(li)Functionmean(li)-> Description: Avearage or mean of elements - shaonutil.stats.mean(list of numbers)Functionmedian(li)-> Description: Median of elements - shaonutil.stats.median(list of numbers)Functionmode(li)-> Description: Mode of elements - shaonutil.stats.mode(list of numbers)StringFunctionnicely_print(dictionary,print)-> Description: Prints the nicely formatted dictionary - shaonutil.strings.nicely_print(object)Functionchange_dic_key(dic,old_key,new_key)-> Description: Change dictionary key with new keyWindowsFunctionis_winapp_admin()-> Description: If the windows app is running with Administrator permissionFunctionget_UAC_permission()-> Description: Get Windows User Account Control Permission for the executing file. If already executing file has admin access, do not ask for permission.Function Usages EndVersioningmajor.minor[.maintenance[.build]](example:1.4.3.5249)adoption: major.minor.patch.maintenance.status.trials_for_successThe last position0 for alpha (status)1 for beta (status)2 for release candidate3 for (final) releaseFor instance:1.2.0.1 instead of 1.2-a11.2.1.2 instead of 1.2-b2 (beta with some bug fixes)1.2.2.3 instead of 1.2-rc3 (release candidate)1.2.3.0 instead of 1.2-r (commercial distribution)1.2.3.5 instead of 1.2-r5 (commercial distribution with many bug fixes)