Mini Shell

Direktori : /proc/self/root/opt/sharedrads/
Upload File :
Current File : //proc/self/root/opt/sharedrads/quick_post

#!/opt/imh-python/bin/python3
import pp_api
import sys
import argparse
import rads
from rads.color import red, green


def get_arguments():
    parser = argparse.ArgumentParser()
    parser.add_argument(
        '-u', '--user', action='store', dest='User', help='Define your User'
    )
    parser.add_argument(
        '-n',
        '--note',
        action='store',
        dest='Note',
        help='Enter the note to post',
    )
    results = parser.parse_args()
    if not results.User:
        results.User = input('Enter cpanel user : ')
    if not rads.is_cpuser(results.User):
        print(red('Not a valid user'))
        sys.exit(1)
    if not results.Note:
        results.Note = input('Enter note for Power Panel : ')
    return results


def post_note_now(user, note):
    whoami = f'{rads.get_login()}@inmotionhosting.com'
    type_ = "Resource Management"
    pp = pp_api.PowerPanel()
    pp_r = pp(
        'hosting.insert-note',
        user=user,
        admin_user=whoami,
        flagged=False,
        type=type_,
        note=f'{whoami}: {note}',
    )
    if pp_r is None or not hasattr(pp_r, 'status') or pp_r.status != 0:
        print(red('Note failed to post. Post manually'))
    else:
        print(green('Successfully posted note'))


def main():
    results = get_arguments()
    post_note_now(results.User, results.Note)


if __name__ == "__main__":
    main()

Zerion Mini Shell 1.0