This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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('----------------------------------') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def directory_checker(): | |
# Checking if the directory exists | |
if os.path.exists(template_dir): | |
return template_dir | |
else: | |
os.makedirs(template_dir) | |
directory_checker() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Simple Service to monitor Directory state. | |
[Service] | |
Type=simple | |
ExecStart=/bin/bash /usr/bin/run_python.sh | |
[Install] | |
WantedBy=multi-user.target |
OlderNewer