EntityScript

Draft 1.01:
Index







Sections: Status -> Approved

1.) EntityScript™ Overview - Overview of the project

2.) .entity/.ds Lookups - Overview of basic .entity and .ds file relationships. An overview of each file.

3.) Special File Types - Overview of special types of methods, files, and types in C.ORE™

4.) Log File Types - Overview of Logging within C.ORE™

5.) Using OpenPackager™ - Overview of the OpenPackager™ project and details regarding using the sub-system for organizing the base system and addons.

6.) Locations - Overview of various parts of the IPDVC™ file system

7.) System Audits - Overview of various audit mechanisms present in C.ORE™ and how to use them.

8.) C.ORE™ Scripts - Overview of scripts that run in C.ORE™, the purpose they have, overview of some scripting philosophy, and some usage examples.

9.) Startup - Step-by-step process of startup routines and how to extend them

10.) C.ORE™: AirEP™ file system (Access Identity Ring Entertainment Platform: AirEP™ - Understand more about the Access, Identity, Ring

11.) Keys: Each of the built-in keys that can be used to retrieve meta-information in C.ORE™

12.) How-to: Additional Notes

13.) Moderation: Basic moderation principles

14.) Social Pledge: Basic social-pledge for your interface and who you interact with

15.) Disclaimers: Basic recommendations for your interface and dealing with various types of commerce

16.) Additional Resources: Dig deeper into the technical stack, program methods, variables, and other happenings within CORE.HOST™

core_server




"""
Copyright (C) 2020 New Entity Operations Inc.

ALL RIGHTS RESERVED

core_server manages your personal server instance

"""
# Imports: Standard
from socket import (
    AF_INET, SOCK_STREAM, socket
)
from threading import (
    current_thread, Thread
)
from socketserver import (
    BaseRequestHandler, ThreadingMixIn, TCPServer
)

from core_middlelayer import (
    encoding_standard,
    SLUG_HOST_PERSONAL, STREAM_VALUE,
    PORTCONNECT_TO
)
# SILO.silo_writer
class SILO:
    """
    Takes an appended THREAD_response from
    STANDARD_HANDLER_TCP_REQUEST.handle
    """
    silo_writer = []

class STANDARD_HANDLER_TCP_REQUEST(BaseRequestHandler):
    """
    STANDARD HANDLER: TCP
    Serve a control instance on port X until killed
    with Ctrl-C or automated as an up/down routine elsewhere
    """
    def handle(self):
     """
     the 'handle(self)' method is a required override.
     we want ascii type requests
     """
     # self.request is the TCP socket
     try:
      data = str(self.request.recv(int(STREAM_VALUE)),
       encoding_standard
      )
      THREAD_now = current_thread()
      THREAD_response = bytes(
       "{}: {}".format(THREAD_now.name, data),
       encoding_standard
      )
      self.request.sendall(THREAD_response)
      print(THREAD_response)
      SILO.silo_writer.append(THREAD_response)
     except:
      UnicodeDecodeError
      print(
       "It's possible you aren't enabling unsigned local certs or there isn't one there."
      )

class STANDARD_HANDLER_TCP_SERVER(
 ThreadingMixIn, TCPServer
):
    """
    Acts as the allocated of each thread.
    'pass' by default as a converted thread object
    """
    pass

def EVENT_INBOUND(ip, port, message):
    """
    ip, port, message style I/O on a socket
    AF_INET and SOCK_STREAM are the protocols in use
    """
    with socket(AF_INET, SOCK_STREAM) as sock:
     try:
      sock.connect((ip, port))
      sock.sendall(bytes(message, encoding_standard))
      THREAD_response = str(sock.recv(STREAM_VALUE), encoding_standard)
      print("Received: {}".format(THREAD_response))
     except:
      ConnectionRefusedError
      print("Connect Error: Possibly no server?")

if __name__ == '__main__':
    # HOST, PORT = "localhost", 19288
    # 0 for an arbitrary unused port
    HOST, PORT = SLUG_HOST_PERSONAL, int(PORTCONNECT_TO)

    try:
     server = \
     STANDARD_HANDLER_TCP_SERVER(
     (HOST, PORT),
     STANDARD_HANDLER_TCP_REQUEST
     )
    except:
     OSError
     pass

    try:
     with server:
      try:
       #***********************************#
       # STEP 7: SERVER Gateway CHECK         #
       #***********************************#
       print(
        "-------- START: STEP 7 - SERVER Gateway CHECK ----------"
       )

       ip, port = server.server_address

       THREAD_server  = Thread(
        target=server.serve_forever
       )
       THREAD_server.daemon = True

       THREAD_server.start()

       print("THREADED SERVER: Up",
        THREAD_server.name
       )

       #EVENT_INBOUND(ip, port, "Hello my friend")
       #EVENT_INBOUND(ip, port, "Hello my friend")
       #EVENT_INBOUND(ip, port, "Hello my foe")
       #EVENT_INBOUND(ip, port, "Hello my All")

       server.serve_forever()
       print(
        "---------- STOP: STEP 7 - SERVER Gateway CHECK ---------\n-"
       )
       #***************************************#
       # STOP: STEP  7 - SERVER Gateway CHECK   #
       #***************************************#

      except:
       KeyboardInterrupt
       print(
        "\n\nThe server was shutdown by the Keyboard-Interrupt: Exiting\n"
       )
       # Write the contents of connections here. Add them to silos to keep track and kill off
       # any that may become unwanted.
       for i in SILO.silo_writer:
           print(i)

      #server.shutdown()

    except:
     #******************************************#
     # START: STEP  7 - SERVER Gateway CHECK      #
     #******************************************#
     NameError
     print(
      "-------- START: STEP  7 - SERVER Gateway CHECK  ----------"
     )
     print(
      "The server-socket is already running."
     )
     print(
      "---------- STOP: STEP  7 - SERVER Gateway CHECK  ----------\n"
     )
     #***************************************#
     # STOP: STEP  7 - SERVER Gateway CHECK  #
     #***************************************#




Return HOME