Skip to content

Instantly share code, notes, and snippets.

View godfather68's full-sized avatar

Farel Ellely godfather68

View GitHub Profile
from django.core.management.base import BaseCommand
class Command(BaseCommand):
help = 'Understanding management command'
def handle(self, *args, **kwrags):
self.stdout.write("Writing management command")
from django.core.management.base import BaseCommand
import os # <= new
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) # <= new
class Command(BaseCommand):
help = "Templates Generator"
def handle(self, *args, **kwrags):
self.stdout.write("Generating _base.html template ...")
self.stdout.write('----------------------------------')
from django.core.management.base import BaseCommand
import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
class Command(BaseCommand):
help = "Templates Generator"
template_dir = os.path.join(BASE_DIR, 'templates')
file_path = os.path.join(template_dir, '_base.html')
from django.core.management.base import BaseCommand
import os #
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
class Command(BaseCommand):
help = "Templates Generator"
template_dir = os.path.join(BASE_DIR, 'templates')
file_path = os.path.join(template_dir, '_base.html')
from django.core.management.base import BaseCommand
import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
class Command(BaseCommand):
help = "Templates Generator"
template_dir = os.path.join(BASE_DIR, 'templates')
def add_arguments(self, parser):
parser.add_argument('template_name', type=str, help="Indicates the template name(e.g home.html)")
# Optional app directory
parser.add_argument('-a', '--app', type=str, help="Defines a parent dir with the name of the app")
def directory_checker():
# Checking if the directory exists
if os.path.exists(template_dir):
return template_dir
else:
os.makedirs(template_dir)
directory_checker()
def directory_checker(self):
# Checking if the directory exists
if os.path.exists(template_dir):
return template_dir
else:
os.makedirs(template_dir)
if os.path.exists(template_dir):
return template_dir
import os
import sys
source_path = os.path.dirname(os.path.abspath(__file__))
# test_files_dir = os.path.join(source_path, "test_files")
if __name__ == '__main__':
files = os.listdir(source_path)
for file in files:
[Unit]
Description=Simple Service to monitor Directory state.
[Service]
Type=simple
ExecStart=/bin/bash /usr/bin/run_python.sh
[Install]
WantedBy=multi-user.target