Sort import, create class DMN
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
"""WordOps Swap Creation"""
|
||||
from wo.core.shellexec import WOShellExec
|
||||
from wo.core.fileutils import WOFileUtils
|
||||
from wo.core.aptget import WOAptGet
|
||||
from wo.core.logging import Log
|
||||
import os
|
||||
|
||||
import psutil
|
||||
|
||||
from wo.core.aptget import WOAptGet
|
||||
from wo.core.fileutils import WOFileUtils
|
||||
from wo.core.logging import Log
|
||||
from wo.core.shellexec import WOShellExec
|
||||
|
||||
|
||||
class WOSwap():
|
||||
"""Manage Swap"""
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
"""WordOps packages repository operations"""
|
||||
import os
|
||||
|
||||
from wo.core.logging import Log
|
||||
from wo.core.shellexec import WOShellExec
|
||||
from wo.core.variables import WOVariables
|
||||
from wo.core.logging import Log
|
||||
import os
|
||||
|
||||
|
||||
class WORepo():
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
"""WordOps package installation using apt-get module."""
|
||||
import apt
|
||||
import sys
|
||||
import subprocess
|
||||
from wo.core.logging import Log
|
||||
import sys
|
||||
|
||||
from sh import ErrorReturnCode, apt_get
|
||||
|
||||
import apt
|
||||
from wo.core.apt_repo import WORepo
|
||||
from sh import apt_get
|
||||
from sh import ErrorReturnCode
|
||||
from wo.core.logging import Log
|
||||
|
||||
|
||||
class WOAptGet():
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import requests
|
||||
|
||||
from wo.core.shellexec import WOShellExec
|
||||
from wo.core.variables import WOVariables
|
||||
import requests
|
||||
|
||||
|
||||
def check_fqdn(self, wo_host):
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from wo.core.shellexec import WOShellExec
|
||||
from wo.core.logging import Log
|
||||
from wo.core.shellexec import WOShellExec
|
||||
|
||||
|
||||
"""
|
||||
Set CRON on LINUX system.
|
||||
|
||||
@@ -3,49 +3,50 @@ import os
|
||||
from urllib.parse import urlparse
|
||||
|
||||
|
||||
def ValidateDomain(url):
|
||||
"""
|
||||
This function returns domain name removing http:// and https://
|
||||
returns domain name only with or without www as user provided.
|
||||
"""
|
||||
class DOMN:
|
||||
|
||||
# Check if http:// or https:// present remove it if present
|
||||
domain_name = url.split('/')
|
||||
if 'http:' in domain_name or 'https:' in domain_name:
|
||||
domain_name = domain_name[2]
|
||||
else:
|
||||
domain_name = domain_name[0]
|
||||
www_domain_name = domain_name.split('.')
|
||||
final_domain = ''
|
||||
if www_domain_name[0] == 'www':
|
||||
final_domain = '.'.join(www_domain_name[1:])
|
||||
else:
|
||||
final_domain = domain_name
|
||||
def validatedomain(self, url):
|
||||
"""
|
||||
This function returns domain name removing http:// and https://
|
||||
returns domain name only with or without www as user provided.
|
||||
"""
|
||||
|
||||
return (final_domain, domain_name)
|
||||
# Check if http:// or https:// present remove it if present
|
||||
domain_name = url.split('/')
|
||||
if 'http:' in domain_name or 'https:' in domain_name:
|
||||
domain_name = domain_name[2]
|
||||
else:
|
||||
domain_name = domain_name[0]
|
||||
www_domain_name = domain_name.split('.')
|
||||
final_domain = ''
|
||||
if www_domain_name[0] == 'www':
|
||||
final_domain = '.'.join(www_domain_name[1:])
|
||||
else:
|
||||
final_domain = domain_name
|
||||
|
||||
return (final_domain, domain_name)
|
||||
|
||||
def GetDomainlevel(domain):
|
||||
"""
|
||||
This function returns the domain type : domain, subdomain,
|
||||
"""
|
||||
domain_name = domain.lower().strip().split('.')
|
||||
if domain_name[0] == 'www':
|
||||
domain_name = domain_name[1:]
|
||||
domain_type = ''
|
||||
if os.path.isfile("/var/lib/wo/public_suffix_list.dat"):
|
||||
# Read mode opens a file for reading only.
|
||||
suffix_file = open(
|
||||
"/var/lib/wo/public_suffix_list.dat", encoding='utf-8', )
|
||||
# Read all the lines into a list.
|
||||
for domain_suffix in suffix_file:
|
||||
if (str(domain_suffix).strip()) == ('.'.join(domain_name[1:])):
|
||||
domain_type = 'domain'
|
||||
root_domain = ('.'.join(domain_name[0:]))
|
||||
break
|
||||
else:
|
||||
domain_type = 'subdomain'
|
||||
root_domain = ('.'.join(domain_name[1:]))
|
||||
suffix_file.close()
|
||||
def getdomainlevel(self, domain):
|
||||
"""
|
||||
This function returns the domain type : domain, subdomain,
|
||||
"""
|
||||
domain_name = domain.lower().strip().split('.')
|
||||
if domain_name[0] == 'www':
|
||||
domain_name = domain_name[1:]
|
||||
domain_type = ''
|
||||
if os.path.isfile("/var/lib/wo/public_suffix_list.dat"):
|
||||
# Read mode opens a file for reading only.
|
||||
suffix_file = open(
|
||||
"/var/lib/wo/public_suffix_list.dat", encoding='utf-8', )
|
||||
# Read all the lines into a list.
|
||||
for domain_suffix in suffix_file:
|
||||
if (str(domain_suffix).strip()) == ('.'.join(domain_name[1:])):
|
||||
domain_type = 'domain'
|
||||
root_domain = ('.'.join(domain_name[0:]))
|
||||
break
|
||||
else:
|
||||
domain_type = 'subdomain'
|
||||
root_domain = ('.'.join(domain_name[1:]))
|
||||
suffix_file.close()
|
||||
|
||||
return (domain_type, root_domain)
|
||||
return (domain_type, root_domain)
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
"""WordOps download core classes."""
|
||||
import urllib.request
|
||||
import urllib.error
|
||||
import os
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
|
||||
from wo.core.logging import Log
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"""WordOps Extract Core """
|
||||
import tarfile
|
||||
import os
|
||||
import tarfile
|
||||
|
||||
from wo.core.logging import Log
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
"""WordOps file utils core classes."""
|
||||
import shutil
|
||||
import fileinput
|
||||
import os
|
||||
import pwd
|
||||
import fileinput
|
||||
import shutil
|
||||
|
||||
from wo.core.logging import Log
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
"""WordOps GIT module"""
|
||||
from sh import git, ErrorReturnCode
|
||||
from wo.core.logging import Log
|
||||
import os
|
||||
|
||||
from sh import ErrorReturnCode, git
|
||||
|
||||
from wo.core.logging import Log
|
||||
|
||||
|
||||
class WOGit:
|
||||
"""Intialization of core variables"""
|
||||
|
||||
@@ -3,10 +3,11 @@
|
||||
Real time log files watcher supporting log rotation.
|
||||
"""
|
||||
|
||||
import os
|
||||
import time
|
||||
import errno
|
||||
import os
|
||||
import stat
|
||||
import time
|
||||
|
||||
from wo.core.logging import Log
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
"""WordOps MySQL core classes."""
|
||||
import pymysql
|
||||
from pymysql import connections, DatabaseError, Error
|
||||
from os.path import expanduser
|
||||
import os
|
||||
from os.path import expanduser
|
||||
|
||||
import pymysql
|
||||
from pymysql import DatabaseError, Error, connections
|
||||
|
||||
from wo.core.logging import Log
|
||||
from wo.core.variables import WOVariables
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
"""WordOps Hash Bucket Calculator"""
|
||||
from wo.core.fileutils import WOFileUtils
|
||||
import fileinput
|
||||
import math
|
||||
import os
|
||||
import fileinput
|
||||
import subprocess
|
||||
|
||||
from wo.core.fileutils import WOFileUtils
|
||||
|
||||
|
||||
def hashbucket(self):
|
||||
# Check Nginx Hashbucket error
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import smtplib
|
||||
import os
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
import smtplib
|
||||
from email import encoders
|
||||
from email.mime.base import MIMEBase
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
from email.mime.text import MIMEText
|
||||
from email.utils import COMMASPACE, formatdate
|
||||
from email import encoders
|
||||
|
||||
|
||||
def WOSendMail(send_from, send_to, subject, text, files, server="localhost",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
"""WordOps Service Manager"""
|
||||
import subprocess
|
||||
|
||||
from wo.core.logging import Log
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
"""WordOps Shell Functions"""
|
||||
from wo.core.logging import Log
|
||||
import subprocess
|
||||
|
||||
from wo.core.logging import Log
|
||||
|
||||
|
||||
class CommandExecutionError(Exception):
|
||||
"""custom Exception for command execution"""
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
from wo.core.logging import Log
|
||||
import os
|
||||
|
||||
from wo.core.logging import Log
|
||||
|
||||
|
||||
"""
|
||||
Render Templates
|
||||
"""
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
"""WordOps core variable module"""
|
||||
import distro
|
||||
import socket
|
||||
import configparser
|
||||
import os
|
||||
import datetime
|
||||
import os
|
||||
import socket
|
||||
|
||||
import distro
|
||||
|
||||
|
||||
class WOVariables():
|
||||
|
||||
Reference in New Issue
Block a user