Simple python logging module wrapper

Simple python logging module wrapper that can be inherited to the class or can be used as a standalone. This logging wrapper supports logging level of INFO, ERROR and DEBUG with option to print to CONSOLE, FILE , BOTH and NONE.  git pull from mlogger repo.

Following is an example

# Inherited to Class
class tester(MLOGGER):
    def __init__(self):
        MLOGGER.__init__(self,'test',logtype='NONE', filename = 'mylogg.log')
    def testmethod(self):
        self.error('error test')
        self.debug('debug test')
        self.warn('warn test')'info test')

t = tester()

# As Standalone
logger= MLOGGER('Test', level=INFO, logtype = 'CONSOLE', filename = 'mylog.log')
logger.debug('debug test')'info test')
logger.warn('warn test')
logger.error('error test')

Python: How to create zip of files?

Download Code From Here

import zipfile
import time
import os

def create_zip(zip_filenames):
  print "Creating ", zipped_name
  zf = zipfile.ZipFile(zipped_name, mode='w')

for filename in zip_filenames:
    print "Adding",filename,"in",zipped_name
    ":::ERROR::: Unable to add file to zipped file"
     print "Created Zipped File",zipped_name 

def remove_files(remove_filesnames):
  for filename in remove_filesnames:
    print "Removing", filename

if __name__=="__main__":

  filenames= ['syspreset001','syspreset0161.prst','zip']

Python: How to download file using FTP?

Download the following script from Here.

#Download File with FTP.
#Download_System requires two variables HOST & directory & filename

import ftplib
import sys

#Host and Gets the Filename of the Preset
def Download_System(HOST,directory,filename):
    ftp_download=ftplib.FTP(HOST) #opens Ftp Connection to the HOST
    ftp_download.login( "root", "root") #username, password
    ftp_download.cwd(directory_get) #Change Directory to file directory
    localfile=open(filename_get,'wb') #Open Localfile to write
    ftp_download.retrbinary("RETR " + filename_get, localfile.write) #Get the Filname in Binary
  except Exception as e:
    print ":::ERROR:::: " +str(e)

if __name__=="__main__":
  Directory='Change Directory Here'

Learning Python GUI using Tkinter

As I wanted to learn the python GUI,
I searched on internet and found these very nice tutorials on how to built GUI using Tkinter library of python. There are few more GUI libraries available on the internet as you may be aware such as wxpython, but I found Tkinter suitable for my needs and easy to work with. I started learning from UsingPython , it also has a good basic python tutorials if you want to have a refresher course.


The other one was the Python Course which also has some really nice examples and a bit more than using python but both are good and you can start from either one.

Following are library references which are handy to know what things you can change using arguments.