Added version to all files, create .new Custom file if already there

This commit is contained in:
Brian Read 2024-04-26 09:26:38 +01:00
parent 7af3086d73
commit b96239639c
9 changed files with 100 additions and 28 deletions

View File

@ -2,6 +2,8 @@
# Routines to be editted by the developer to provide validation for parameters
# and provison of the control data for table(s)
#
# Generated by SM2Gen version:${version}
#
#$cdb=$main::cdb;
#$adb=$main::adb;
#$ndb=$main::ndb;

View File

@ -0,0 +1,49 @@
#
# Routines to be editted by the developer to provide validation for parameters
# and provison of the control data for table(s)
#
#$cdb=$main::cdb;
#$adb=$main::adb;
#$ndb=$main::ndb;
#$hdb=$main::hdb;
#$ddb=$main::ddb;
use esmith::util;
use esmith::HostsDB;
use esmith::AccountsDB;
use esmith::NetworksDB;
use esmith::HostsDB;
use esmith::DomainsDB;
#The most common ones
our $cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
our $adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db");
our $ndb = esmith::NetworksDB->open() || die("Couldn't open Network db");
our $hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db");
our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
# Validation routines - parameters for each panel
sub validate_PARAMS {
$ret = 'ok';
return $ret;
}
sub validate_TABLE {
$ret = 'ok';
return $ret;
}
# Get control data for tables(s)
sub get_ibays {
return []
}
1;

View File

@ -1,22 +1,22 @@
'nfs_These parameters will be effective only if the share is enabled. The share is in /home/e-smith/files/ibays//files' => 'These parameters will be effective only if the share is enabled. The share is in /home/e-smith/files/ibays//files'
'nfs_For writing permissions,allowing the root user and using insecure ports, you must configure a list of one IP per line, being part of the local network(s).' => 'For writing permissions,allowing the root user and using insecure ports, you must configure a list of one IP per line, being part of the local network(s).'
'nfs_Share owner Group' => 'Share owner Group'
'nfs_Squash the power of users' => 'Squash the power of users'
'nfs_$thispanel successfull message' => '$thispanel successfull message'
'nfs Hello TABLE' => 'Hello TABLE'
'nfs_Set the UID.' => 'Set the UID.'
'nfs_NFS Client(s) allowed' => 'NFS Client(s) allowed'
'nfs Hello PARAMS' => 'Hello PARAMS'
'nfs_Delays the disk writing' => 'Delays the disk writing'
'nfs_Save' => 'Save'
'nfs_Set the uid and gid if you want all requests appear to be from one user or one group, otherwise leave blank' => 'Set the uid and gid if you want all requests appear to be from one user or one group, otherwise leave blank'
'nfs_EnableShare on local network' => 'EnableShare on local network'
'nfs_Set the GID.' => 'Set the GID.'
'nfs_APPLY' => 'APPLY'
'nfs_NFS data share' => 'NFS data share'
'nfs_File system permissions' => 'File system permissions'
'nfs_Requests on secure ports' => 'Requests on secure ports'
'nfs_$thispanel successfull message' => '$thispanel successfull message'
'nfs Hello TABLE' => 'Hello TABLE'
'nfs_For writing permissions,allowing the root user and using insecure ports, you must configure a list of one IP per line, being part of the local network(s).' => 'For writing permissions,allowing the root user and using insecure ports, you must configure a list of one IP per line, being part of the local network(s).'
'nfs_Write (a)synchronously' => 'Write (a)synchronously'
'nfs_Delays the disk writing' => 'Delays the disk writing'
'nfs_Share owner Group' => 'Share owner Group'
'nfs_File system permissions' => 'File system permissions'
'nfs_EnableShare on local network' => 'EnableShare on local network'
'nfs_Squash the power of users' => 'Squash the power of users'
'nfs_Set the GID.' => 'Set the GID.'
'nfs_These parameters will be effective only if the share is enabled. The share is in /home/e-smith/files/ibays//files' => 'These parameters will be effective only if the share is enabled. The share is in /home/e-smith/files/ibays//files'
'nfs_Enable the NFS Share' => 'Enable the NFS Share'
'nfs_APPLY' => 'APPLY'
'nfs_Requests on secure ports' => 'Requests on secure ports'
'nfs_Browse the parent folders' => 'Browse the parent folders'
'nfs_NFS Client(s) allowed' => 'NFS Client(s) allowed'
'nfs Hello PARAMS' => 'Hello PARAMS'
'nfs_Information Bay name' => 'Information Bay name'
'nfs_Set the UID.' => 'Set the UID.'

View File

@ -1,5 +1,7 @@
package SrvMngr::Controller::${PackageName};
#
# Generated by SM2Gen version:${version}
#
#----------------------------------------------------------------------
# heading : ${MenuHeading}
# description : ${MenuDescription}

View File

@ -2,11 +2,9 @@
# Routines to be editted by the developer to provide validation for parameters
# and provison of the control data for table(s)
#
#$cdb=$main::cdb;
#$adb=$main::adb;
#$ndb=$main::ndb;
#$hdb=$main::hdb;
#$ddb=$main::ddb;
#
# Generated by SM2Gen version:${version}
#
use esmith::util;
use esmith::HostsDB;

View File

@ -98,7 +98,7 @@
</password>
<Table><![CDATA[
<table class="sme-border TableSort">
<br /><table class="sme-border TableSort">
<thead>
<tr><tal:block tal:repeat="ColHead TopHeadings">
<th class='sme-border'>${ColHead}</th></tal:block>

View File

@ -1,4 +1,7 @@
% layout 'default', title => "Sme server 2 - ${MenuDescription}", share_dir => './';
%#
%# Generated by SM2Gen version:${version}
%#
% content_for 'module' => begin
<div id="module" class="module ${PackageName}-panel">

View File

@ -1,3 +1,6 @@
%#
%# Generated by SM2Gen version:${version}
%#
<div id="${PackageName}-${route}">
<script>
window.onload = function() {

View File

@ -7,14 +7,28 @@ import pkg_resources
import xml.etree.ElementTree as ET
import re
import os
import pkg_resources
from datetime import datetime
import xml.etree.ElementTree as ET
SME2Gen_version = '0.6'
version = 0.6
try:
chameleon_version = pkg_resources.get_distribution("Chameleon").version
except pkg_resources.DistributionNotFound:
chameleon_version = "Version information not available"
python_version = sys.version
python_version = python_version[:8]
current_datetime = datetime.now()
formatted_datetime = current_datetime.strftime("%Y-%m-%d %H:%M")
strVersion = "SME2Gen version:"+SME2Gen_version+" Chameleon version:"+chameleon_version+" On Python:"+python_version+" at "+formatted_datetime
json5_dict: dict = {}
json5_html_list: list = []
print(f"Generate SM2 code from JSON5 - Version {version}")
print(f"SM2 code from JSON5 - {strVersion}")
quit()
# Get the version of Chameleon using pkg_resources
try:
version = pkg_resources.get_distribution("Chameleon").version
@ -146,6 +160,8 @@ def has_file_been_modified(file_path):
# Get the file's creation time and last modification time in Unix timestamp
creation_time = os.path.getctime(file_path)
last_modification_time = os.path.getmtime(file_path)
print(f"{creation_time}*{last_modification_time}")
quit()
# Compare the creation time and last modification time
if creation_time < last_modification_time:
@ -153,9 +169,6 @@ def has_file_been_modified(file_path):
else:
return False # File has not been modified after creation
import xml.etree.ElementTree as ET
def parse_xml_to_dict(xml_file):
# Parse the XML file
tree = ET.parse(xml_file)
@ -226,7 +239,9 @@ if __name__ == "__main__":
controller_file = 'Targets/'+hl('PackageName')+'.pm'
custom_controller_file = 'Targets/'+hl('PackageName')+'-Custom.pm'
# see if it has been modified by developer
if has_file_been_modified(custom_controller_file):
#if has_file_been_modified(custom_controller_file):
# custom_controller_file = custom_controller_file+'.new'
if os.path.exists(custom_controller_file):
custom_controller_file = custom_controller_file+'.new'
layout_file = 'Targets/'+hl('PackageName')+'.html.ep'
partial_files = list()