#!/usr/bin/env python3
import os
import subprocess
import sys
import time


sys.path.insert(0, "/opt/oglive/rootfs/opt/opengnsys/lib/python3/")
sys.path.insert(0, "/opt/opengnsys/interfaceAdm/git/")
sys.path.insert(0, "/opt/opengnsys/ogrepository/oggit/lib/")

import NetLib
import ogGlobals
import SystemLib


from gitlib import OpengnsysGitLibrary, NTFSImplementation


def create_image(disk_num, partition_num, repo, image_name):

    ntfs_impl = NTFSImplementation.NTFS3G
    og_git = OpengnsysGitLibrary(ntfs_implementation = ntfs_impl)
    device = og_git._runBashFunction("ogDiskToDev", [str(disk_num), str(partition_num)])
    og_git.initRepo(device, image_name)

def main():
    if len(sys.argv) != 6:
        sys.exit(SystemLib.ogRaiseError(OG_ERR_FORMAT, "Incorrect number of arguments"))

    disk_num, partition_num, image_name, repo, tag = sys.argv[1:6]

    retval = create_image(disk_num, partition_num, repo, image_name)

    sys.exit(retval)

if __name__ == "__main__":
    main()
