Code modification
This commit is contained in:
parent
eda8aca0c2
commit
8d170ffbb9
|
|
@ -21,7 +21,7 @@ class Danix():
|
||||||
else:
|
else:
|
||||||
return du(f'{MAIN_REPO}.snapshots/{snapshot_name}/{environment_name}.tar.gz','-ch').split('\n')[-2].split('\t')[0]
|
return du(f'{MAIN_REPO}.snapshots/{snapshot_name}/{environment_name}.tar.gz','-ch').split('\n')[-2].split('\t')[0]
|
||||||
except Exception:
|
except Exception:
|
||||||
return "0M"
|
return "000M"
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def make_snapshot(filesystem_name, snapshot_name):
|
def make_snapshot(filesystem_name, snapshot_name):
|
||||||
|
|
|
||||||
|
|
@ -1,119 +1,175 @@
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
from django.db.models import Q
|
||||||
import uuid
|
import uuid
|
||||||
from danixfs import Danix
|
from danixfs import Danix
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from settings import SNAPSHOT_LIMIT
|
from settings import SNAPSHOT_LIMIT
|
||||||
|
from utils import is_unique_database_tuple, get_message, check_equal_sentence, check_not_equal_sentence
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
|
|
||||||
|
def get_queryset_filtered(model, sub_attribute):
|
||||||
|
|
||||||
|
if model == Environment:
|
||||||
|
return model.objects.filter(filesystem_name__startswith=sub_attribute)
|
||||||
|
|
||||||
|
return model.objects.filter(snapshot__startswith=sub_attribute)
|
||||||
|
|
||||||
class Environment(models.Model):
|
class Environment(models.Model):
|
||||||
filesystem_name = models.UUIDField()
|
filesystem_name = models.UUIDField()
|
||||||
status = models.BooleanField(default=True)
|
status = models.BooleanField(default=True)
|
||||||
name = models.TextField()
|
name = models.TextField()
|
||||||
created = models.DateField(default=datetime.now())
|
created = models.DateField(default=datetime.now())
|
||||||
template = models.TextField(default="")
|
template = models.TextField(default="")
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def navigate(filesystem_name):
|
def navigate(filesystem_name):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
environment = Environment.objects.filter(filesystem_name=filesystem_name)
|
environment = get_queryset_filtered(Environment, filesystem_name)
|
||||||
|
environments_count = environment.count()
|
||||||
|
environment_first = environment.first()
|
||||||
|
|
||||||
|
if check_equal_sentence(environments_count, 0):
|
||||||
|
|
||||||
|
get_message(message=settings.ENV_NOT_FOUND, is_finishprogram=True, finish_status_code=1)
|
||||||
|
|
||||||
|
expression = is_unique_database_tuple(environment) and environment_first.status
|
||||||
|
|
||||||
|
if expression:
|
||||||
|
resp = Danix.navigate(environment_first.filesystem_name)
|
||||||
|
|
||||||
|
if not check_not_equal_sentence(resp, 0):
|
||||||
|
|
||||||
|
get_message(
|
||||||
|
message=settings.ENV_GENERIC_ERROR,
|
||||||
|
is_finishprogram=True,
|
||||||
|
finish_status_code=1
|
||||||
|
)
|
||||||
|
|
||||||
|
elif expression ^ (not environment.status):
|
||||||
|
|
||||||
|
get_message(
|
||||||
|
message=settings.ENV_STOPPED_ERROR,
|
||||||
|
is_finishprogram=True,
|
||||||
|
finish_status_code=1
|
||||||
|
)
|
||||||
|
|
||||||
if environment.count() == 0:
|
|
||||||
print("Environment does not exist!")
|
|
||||||
exit(1)
|
|
||||||
else:
|
else:
|
||||||
if environment.first().status:
|
get_message(
|
||||||
|
message=settings.ENV_PATTERN_ERROR,
|
||||||
resp = Danix.navigate(filesystem_name)
|
is_finishprogram=True,
|
||||||
|
finish_status_code=1
|
||||||
if resp != 0:
|
)
|
||||||
print("Error!")
|
|
||||||
exit(1)
|
except ValidationError:
|
||||||
else:
|
get_message(
|
||||||
print("Error! The environment is spopped!")
|
message=settings.ENV_PATTERN_ERROR,
|
||||||
exit(1)
|
is_finishprogram=True,
|
||||||
|
finish_status_code=1
|
||||||
except ValidationError as error:
|
)
|
||||||
print("Environment doenst not exist!")
|
|
||||||
exit(1)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def rm_environment(filesystem_name):
|
def rm_environment(filesystem_name):
|
||||||
try:
|
try:
|
||||||
environment = Environment.objects.filter(filesystem_name=filesystem_name)
|
environment = Environment.objects.filter(filesystem_name=filesystem_name)
|
||||||
|
environment_count = environment.count()
|
||||||
|
environment = environment.first()
|
||||||
|
|
||||||
if environment.count() == 0:
|
if check_equal_sentence(environment_count, 0):
|
||||||
print("Environment does not exist!")
|
|
||||||
exit(1)
|
get_message(
|
||||||
else:
|
message=settings.ENV_NOT_FOUND,
|
||||||
|
is_finishprogram=True,
|
||||||
|
finish_status_code=1
|
||||||
|
)
|
||||||
|
|
||||||
|
Danix.rm(filesystem_name)
|
||||||
|
environment.delete()
|
||||||
|
|
||||||
|
get_message(
|
||||||
|
message=f"{settings.ENV_REMOVED} - {filesystem_name}",
|
||||||
|
is_finishprogram=False,
|
||||||
|
finish_status_code=-1
|
||||||
|
)
|
||||||
|
|
||||||
Danix.rm(filesystem_name)
|
|
||||||
env = environment.first()
|
|
||||||
env.delete()
|
|
||||||
print(f"Environment removed successfully! - {filesystem_name}")
|
|
||||||
except Exception:
|
except Exception:
|
||||||
print("Environment does not exist!")
|
get_message(
|
||||||
exit(1)
|
message=settings.ENV_NOT_FOUND,
|
||||||
|
is_finishprogram=True,
|
||||||
|
finish_status_code=1
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def start_environment(filesystem_name):
|
def start_environment(filesystem_name):
|
||||||
|
|
||||||
environment = Environment.objects.filter(filesystem_name=filesystem_name)
|
environment = Environment.objects.filter(filesystem_name=filesystem_name)
|
||||||
|
environment_counter = environment.count()
|
||||||
|
environment = environment.first()
|
||||||
|
|
||||||
|
if check_equal_sentence(environment_counter, 0):
|
||||||
|
|
||||||
|
get_message(
|
||||||
|
message=settings.ENV_NOT_FOUND,
|
||||||
|
is_finishprogram=True,
|
||||||
|
finish_status_code=1
|
||||||
|
)
|
||||||
|
|
||||||
|
environment.status = True
|
||||||
|
environment.save()
|
||||||
|
|
||||||
|
get_message(
|
||||||
|
message=settings.ENV_STARTED,
|
||||||
|
is_finishprogram=True,
|
||||||
|
finish_status_code=1
|
||||||
|
)
|
||||||
|
|
||||||
if environment.count() == 0:
|
|
||||||
|
|
||||||
print("Environment does not exist!")
|
|
||||||
exit(1)
|
|
||||||
else:
|
|
||||||
env = environment.first()
|
|
||||||
env.status = True
|
|
||||||
env.save()
|
|
||||||
print("Environment started successfully!")
|
|
||||||
exit(0)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def set_active(filesystem_name):
|
def set_active(filesystem_name):
|
||||||
environment = Environment.objects.filter(filesystem_name=filesystem_name).first()
|
|
||||||
|
|
||||||
|
environment = Environment.objects.filter(filesystem_name=filesystem_name).first()
|
||||||
environment.status = True
|
environment.status = True
|
||||||
environment.save()
|
environment.save()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def stop_environment(filesystem_name):
|
def stop_environment(filesystem_name):
|
||||||
|
|
||||||
|
|
||||||
environment = Environment.objects.filter(filesystem_name=filesystem_name)
|
environment = Environment.objects.filter(filesystem_name=filesystem_name)
|
||||||
|
environment_counter = environment.count()
|
||||||
|
environment = environment.first()
|
||||||
|
|
||||||
if environment.count() == 0:
|
if check_equal_sentence(environment_counter, 0):
|
||||||
print("Environment does not exist!")
|
|
||||||
exit(1)
|
get_message(message=settings.ENV_NOT_FOUND, is_finishprogram=True, finish_status_code=1)
|
||||||
else:
|
|
||||||
env = environment.first()
|
environment.status = False
|
||||||
env.status = False
|
environment.save()
|
||||||
env.save()
|
|
||||||
print("Environment stopped successfully!")
|
get_message(message=settings.ENV_STOPPED, is_finishprogram=True, finish_status_code=1)
|
||||||
exit(0)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def list_environments():
|
def list_environments():
|
||||||
|
|
||||||
environments = Environment.objects.all()
|
environments = Environment.objects.all()
|
||||||
|
environment_counter = environments.count()
|
||||||
|
|
||||||
print("===============================================================================================================================================")
|
print("===============================================================================================================================================")
|
||||||
print("| ENVIRONMENT NAME | TEMPLATE | CREATED | SUBSYSTEM NAME | IMAGE | STATUS | SIZE |")
|
print("| ENVIRONMENT NAME | TEMPLATE | CREATED | SUBSYSTEM NAME | IMAGE | STATUS | SIZE |")
|
||||||
print("|=============================================================================================================================================|")
|
print("|=============================================================================================================================================|")
|
||||||
|
|
||||||
if environments.count() > 0:
|
if environment_counter > 0:
|
||||||
for environment in environments:
|
|
||||||
name = str(environment.name)
|
|
||||||
status_icon = "🟢 Running" if environment.status else "🔴 Stopped"
|
|
||||||
repeat = (11-len(name)) * '.'
|
|
||||||
|
|
||||||
|
for environment in environments:
|
||||||
|
|
||||||
|
name = str(environment.name)
|
||||||
|
|
||||||
|
status_icon = "🟢 Running" if environment.status else "🔴 Stopped"
|
||||||
template = str(environment.template)
|
template = str(environment.template)
|
||||||
|
|
||||||
repeat_template = (6-len(template)) * ' '
|
|
||||||
|
|
||||||
size = Danix.get_size(environment.filesystem_name, None)
|
size = Danix.get_size(environment.filesystem_name, None)
|
||||||
print(f"| {name[0:11]}{repeat} {template}{repeat_template} {environment.created} {environment.filesystem_name} Alpine {status_icon} {size}B |")
|
|
||||||
|
print(f"| {name[0:11]}{(11-len(name)) * '.'} {template}{(6-len(template)) * ' '} {environment.created} {environment.filesystem_name} Alpine {status_icon} {size}B |")
|
||||||
|
|
||||||
print("===============================================================================================================================================")
|
print("===============================================================================================================================================")
|
||||||
|
|
||||||
|
|
@ -132,25 +188,24 @@ class Snapshot(models.Model):
|
||||||
def rm_snapshot(snapshot_name):
|
def rm_snapshot(snapshot_name):
|
||||||
try:
|
try:
|
||||||
snapshot = Snapshot.objects.filter(snapshot_name=snapshot_name)
|
snapshot = Snapshot.objects.filter(snapshot_name=snapshot_name)
|
||||||
|
|
||||||
|
snapshot_counter = snapshot.count()
|
||||||
|
|
||||||
if snapshot.count() > 0:
|
if snapshot_counter > 0:
|
||||||
|
|
||||||
resp = Danix.remove_snapshot(snapshot_name)
|
resp = Danix.remove_snapshot(snapshot_name)
|
||||||
|
|
||||||
if resp == 0:
|
if check_equal_sentence(resp, 0):
|
||||||
Snapshot.objects.get(snapshot_name=snapshot_name).delete()
|
Snapshot.objects.get(snapshot_name=snapshot_name).delete()
|
||||||
|
|
||||||
print(f"Snapshot removed successfully - {snapshot_name}")
|
get_message(message=f"Snapshot removed successfully - {snapshot_name}", is_finishprogram=False, finish_status_code=-1)
|
||||||
else:
|
|
||||||
print("Error: Snapshot can not remove")
|
get_message(message="Error: Snapshot can not remove", is_finishprogram=True, finish_status_code=1)
|
||||||
exit(1)
|
|
||||||
else:
|
get_message(message="Snapshot does not exist!", is_finishprogram=True, finish_status_code=1)
|
||||||
print("Snapshot does not exist!")
|
|
||||||
exit(1)
|
|
||||||
|
|
||||||
except ValidationError:
|
except ValidationError:
|
||||||
print("Snapshot does not exist!")
|
get_message(message="Snapshot does not exist!", is_finishprogram=True, finish_status_code=1)
|
||||||
exit(1)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def back_snapshot(snapshot_name):
|
def back_snapshot(snapshot_name):
|
||||||
|
|
@ -158,23 +213,21 @@ class Snapshot(models.Model):
|
||||||
snapshot = Snapshot.objects.filter(snapshot_name=snapshot_name)
|
snapshot = Snapshot.objects.filter(snapshot_name=snapshot_name)
|
||||||
|
|
||||||
if snapshot.count() > 0:
|
if snapshot.count() > 0:
|
||||||
|
|
||||||
filesystem_name = Environment.objects.filter(id=snapshot.first().environment_id.id).first().filesystem_name
|
filesystem_name = Environment.objects.filter(id=snapshot.first().environment_id.id).first().filesystem_name
|
||||||
|
|
||||||
resp = Danix.back_snapshot(filesystem_name, snapshot_name)
|
resp = Danix.back_snapshot(filesystem_name, snapshot_name)
|
||||||
|
|
||||||
if resp == 0:
|
if check_equal_sentence(resp, 0):
|
||||||
print("Snapshot backed successfully")
|
get_message(message="Snapshot roll back successfully!", is_finishprogram=True, finish_status_code=0)
|
||||||
exit(0)
|
|
||||||
else:
|
|
||||||
print("Error: Snapshot can not back")
|
|
||||||
exit(1)
|
|
||||||
else:
|
|
||||||
print("Snapshot does not exist!")
|
|
||||||
exit(1)
|
|
||||||
except ValidationError:
|
|
||||||
|
|
||||||
print("Snapshot does not exist!")
|
get_message(message="Error: Snapshot can not back", is_finishprogram=True, finish_status_code=1)
|
||||||
exit(1)
|
|
||||||
|
get_message(message="Snapshot does not exist!", is_finishprogram=True, finish_status_code=1)
|
||||||
|
|
||||||
|
except ValidationError:
|
||||||
|
|
||||||
|
get_message(message="Snapshot does not exist!", is_finishprogram=True, finish_status_code=1)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create(subsystem_name):
|
def create(subsystem_name):
|
||||||
|
|
@ -185,8 +238,7 @@ class Snapshot(models.Model):
|
||||||
snapshots = Snapshot.objects.filter(environment_id=environment_id)
|
snapshots = Snapshot.objects.filter(environment_id=environment_id)
|
||||||
|
|
||||||
if snapshots.count() >= int(SNAPSHOT_LIMIT):
|
if snapshots.count() >= int(SNAPSHOT_LIMIT):
|
||||||
print("Snapshot limit exceeded! Please remove 1 snapshot to continue")
|
get_message(message="Snapshot limit exceeded! Please remove 1 snapshot to continue!", is_finishprogram=True, finish_status_code=1)
|
||||||
exit(1)
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
for snapshot in snapshots:
|
for snapshot in snapshots:
|
||||||
|
|
@ -197,10 +249,11 @@ class Snapshot(models.Model):
|
||||||
snapshot_name = uuid.uuid4()
|
snapshot_name = uuid.uuid4()
|
||||||
|
|
||||||
print('Wait a minute! Taking snapshot')
|
print('Wait a minute! Taking snapshot')
|
||||||
|
|
||||||
snapshot = Snapshot.objects.create(snapshot_name=snapshot_name,environment_id=environment).save()
|
snapshot = Snapshot.objects.create(snapshot_name=snapshot_name,environment_id=environment).save()
|
||||||
resp = Danix.make_snapshot(subsystem_name, snapshot_name)
|
resp = Danix.make_snapshot(subsystem_name, snapshot_name)
|
||||||
|
|
||||||
if resp == 0:
|
if check_equal_sentence(resp, 0):
|
||||||
print("Snapshot created successfully")
|
print("Snapshot created successfully")
|
||||||
print(f"Snapshot name {snapshot_name}\n")
|
print(f"Snapshot name {snapshot_name}\n")
|
||||||
print(f"======================================")
|
print(f"======================================")
|
||||||
|
|
@ -215,8 +268,7 @@ class Snapshot(models.Model):
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
print("Snapshot create error: Environment does not exist!")
|
get_message(message="Snapshot create error: Environment does not exist!", is_finishprogram=True, finish_status_code=1)
|
||||||
exit(1)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def list_snapshots():
|
def list_snapshots():
|
||||||
|
|
@ -235,12 +287,11 @@ class Snapshot(models.Model):
|
||||||
|
|
||||||
if snapshot.environment_id:
|
if snapshot.environment_id:
|
||||||
|
|
||||||
|
|
||||||
environment_name = Environment.objects.filter(id=snapshot.environment_id.id).first().filesystem_name
|
environment_name = Environment.objects.filter(id=snapshot.environment_id.id).first().filesystem_name
|
||||||
size = Danix.get_size(environment_name, name)
|
size = Danix.get_size(environment_name, name)
|
||||||
else:
|
else:
|
||||||
repeated = 14*' '
|
|
||||||
environment_name = f'Environment Removed 🔴{repeated}'
|
environment_name = f'Environment Removed 🔴{14*" "}'
|
||||||
size = "---"
|
size = "---"
|
||||||
|
|
||||||
print(f"| {name} {environment_name} {snapshot.created} {lastsnapshot_icon} {size}B |")
|
print(f"| {name} {environment_name} {snapshot.created} {lastsnapshot_icon} {size}B |")
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,14 @@ ROOT_FS=danixfs.tar.gz
|
||||||
DANIX_PATH=$(shell pwd)
|
DANIX_PATH=$(shell pwd)
|
||||||
REPO_NAME=https://silvavinicius.com.br/danixfs/
|
REPO_NAME=https://silvavinicius.com.br/danixfs/
|
||||||
|
|
||||||
|
ENV_GENERIC_ERROR=Error!
|
||||||
|
ENV_NOT_FOUND=Environment does not exist!
|
||||||
|
ENV_REMOVED=Environment removed successfully!
|
||||||
|
ENV_STARTED=Environment started successfully!
|
||||||
|
ENV_STOPPED=Environment stopped successfully!
|
||||||
|
ENV_STOPPED_ERROR=Error! The environment is stopped!
|
||||||
|
ENV_PATTERN_ERROR=Environment name pattern contains in multiples environments
|
||||||
|
|
||||||
config:
|
config:
|
||||||
|
|
||||||
@mkdir $(MAIN_REPO) > /dev/null 2>&1
|
@mkdir $(MAIN_REPO) > /dev/null 2>&1
|
||||||
|
|
@ -16,6 +24,13 @@ config:
|
||||||
@echo MAIN_REPO=$(MAIN_REPO) >> $(DANIX_PATH)/.env
|
@echo MAIN_REPO=$(MAIN_REPO) >> $(DANIX_PATH)/.env
|
||||||
@echo ROOT_FS=$(ROOT_FS) >> $(DANIX_PATH)/.env
|
@echo ROOT_FS=$(ROOT_FS) >> $(DANIX_PATH)/.env
|
||||||
@echo SNAPSHOT_LIMIT=$(SNAPSHOT_LIMIT) >> $(DANIX_PATH)/.env
|
@echo SNAPSHOT_LIMIT=$(SNAPSHOT_LIMIT) >> $(DANIX_PATH)/.env
|
||||||
|
@echo ENV_NOT_FOUND=$(ENV_NOT_FOUND) >> $(DANIX_PATH)/.env
|
||||||
|
@echo ENV_GENERIC_ERROR=$(ENV_GENERIC_ERROR) >> $(DANIX_PATH)/.env
|
||||||
|
@echo ENV_STOPPED_ERROR=$(ENV_STOPPED_ERROR) >> $(DANIX_PATH)/.env
|
||||||
|
@echo ENV_PATTERN_ERROR=$(ENV_PATTERN_ERROR) >> $(DANIX_PATH)/.env
|
||||||
|
@echo ENV_REMOVED=$(ENV_REMOVED) >> $(DANIX_PATH)/.env
|
||||||
|
@echo ENV_STARTED=$(ENV_STARTED) >> $(DANIX_PATH)/.env
|
||||||
|
@echo ENV_STOPPED=$(ENV_STOPPED) >> $(DANIX_PATH)/.env
|
||||||
|
|
||||||
@touch $(DANIX_PATH)/db/$(DB_NAME) > /dev/null 2>&1
|
@touch $(DANIX_PATH)/db/$(DB_NAME) > /dev/null 2>&1
|
||||||
@$(PIP) install -r $(DANIX_PATH)/requirements.txt > /dev/null 2>&1
|
@$(PIP) install -r $(DANIX_PATH)/requirements.txt > /dev/null 2>&1
|
||||||
|
|
|
||||||
|
|
@ -82,16 +82,25 @@ TEMPLATES = [
|
||||||
WSGI_APPLICATION = 'wsgi.application'
|
WSGI_APPLICATION = 'wsgi.application'
|
||||||
|
|
||||||
|
|
||||||
|
ENV_NOT_FOUND=env('ENV_NOT_FOUND')
|
||||||
|
ENV_GENERIC_ERROR=env('ENV_GENERIC_ERROR')
|
||||||
|
ENV_STOPPED_ERROR=env('ENV_STOPPED_ERROR')
|
||||||
|
ENV_PATTERN_ERROR=env('ENV_PATTERN_ERROR')
|
||||||
|
ENV_REMOVED=env('ENV_REMOVED')
|
||||||
|
ENV_STARTED=env('ENV_STARTED')
|
||||||
|
ENV_STOPPED=env('ENV_STOPPED')
|
||||||
|
|
||||||
|
|
||||||
# Database
|
# Database
|
||||||
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
|
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
|
||||||
|
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django.db.backends.sqlite3',
|
'ENGINE': 'django.db.backends.sqlite3',
|
||||||
'NAME': BASE_DIR / 'danix/db/db.sqlite3',
|
'NAME': f"{MAIN_DIR}/db/db.sqlite3",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
print(DATABASES)
|
||||||
|
|
||||||
# Password validation
|
# Password validation
|
||||||
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
|
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,25 @@
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def check_equal_sentence(left_expression, right_expression):
|
||||||
|
return left_expression == right_expression
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def check_not_equal_sentence(left_expression, right_expression):
|
||||||
|
return left_expression == right_expression
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def is_unique_database_tuple(model_queryset):
|
||||||
|
|
||||||
|
return True if model_queryset.count() == 1 else False
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_message(message, is_finishprogram, finish_status_code):
|
||||||
|
|
||||||
|
print(message)
|
||||||
|
|
||||||
|
if is_finishprogram:
|
||||||
|
exit(finish_status_code)
|
||||||
|
|
||||||
def is_root():
|
def is_root():
|
||||||
return True if os.geteuid() == 0 else False
|
return True if os.geteuid() == 0 else False
|
||||||
Loading…
Reference in New Issue