示例#1
0
def modify_add(tar_file, srch, indicator, action, place):
    """Functions for adding a string to file"""
    text.text_formatting("-> adding " + action + " to " + tar_file, 1, 'info')
    a = get_prop(tar_file)

    try:
        if place == "last":
            open(tar_file, "a").write("\n" + action)
        else:

            with open(tar_file) as fin, NamedTemporaryFile(
                    dir='.', delete=False) as fout:
                counter = 0
                for line in fin:
                    if place == "first" and counter == 0:
                        line = action + "\n" + line
                    elif srch in line:
                        position = line.find(indicator)
                        if place == "previous":
                            line = line[:position] + action + line[position:]
                        elif place == "next":
                            line = line[:position +
                                        len(indicator)] + action + line[
                                            position + len(indicator):]
                        elif place == "after":
                            line = line + action + "\n"
                        elif place == "before":
                            line = action + "\n" + line
                    fout.write(line.encode('utf8'))
                    counter = counter + 1
                shutil.move(fout.name, tar_file)
                set_prop(tar_file, a)
    except:
        text.text_formatting(_("Couldn't found target file"), 1, 'error')
示例#2
0
def modify_rmv(tar_file,srch,indicator,action,place,rplc,indent):
    """Functions for removing string from file"""
    a = get_prop(tar_file)
    text.text_formatting("-> removing " + action + " from " + tar_file, 1, 'info')
    try:
        with open(tar_file) as fin, NamedTemporaryFile(dir='.', delete=False) as fout:
            counter = 0
            for line in fin:
                if place == "first" and counter == 0:
                    line = line.replace(action,rplc)
                elif srch in line:
                    position = line.find(indicator)
                    if place == "previous":
                        line = line[:position].replace(action,rplc).strip() + line[position:]
                    elif place == "next":
                        if indent >0:
                            tabs = " "
                            line = line[:position] + line[position:].replace(action,rplc)
                            for i in range(indent):
                                line = tabs + line
                        else:
                            line = line[:position] + line[position:].replace(action,rplc)
                if place == "after" or place == "before":
                    if action in line:
                        line = ""
                fout.write(line.encode('utf8'))
                counter = counter + 1
            os.rename(fout.name, tar_file)
            set_prop(tar_file,a)
    except:
        text.text_formatting(_("Couldn't found target file"),1, 'error')
示例#3
0
def modify_add(tar_file,srch,indicator,action,place):
    """Functions for adding a string to file"""
    text.text_formatting("-> adding " + action + " to " + tar_file, 1, 'info')
    a = get_prop(tar_file)

    try:
        if place == "last":
            open(tar_file,"a").write("\n" + action)
        else:
            
            with open(tar_file) as fin, NamedTemporaryFile(dir='.', delete=False) as fout:
                counter = 0
                for line in fin:
                    if place == "first" and counter == 0:
                        line = action + "\n" + line
                    elif srch in line:
                        position = line.find(indicator)
                        if place == "previous":
                            line = line[:position] + action + line[position:]
                        elif place == "next":
                            line = line[:position+len(indicator)] + action + line[position+len(indicator):]
                        elif place == "after":
                            line = line + action + "\n"
                        elif place == "before":
                            line = action + "\n" + line
                    fout.write(line.encode('utf8'))
                    counter = counter + 1
                shutil.move(fout.name, tar_file)
                set_prop(tar_file,a)
    except:
        text.text_formatting(_("Couldn't found target file"), 1, 'error')
示例#4
0
def remove(source, rmv_type, dep_source):
    if not suprapackage_check(source):
        text.text_formatting(_("This suprapackage is not installed."), 0,
                             'error')
        sys.exit(1)
    text.text_formatting(">> " + source + _(" suprapackage is removing"), 0,
                         'info')
    if rmv_type == "complete":
        relationship.dependencies(source, "remove")
    local_dep = search.local_dependency(source, " ")

    if (len(local_dep) == 1 and not "" in local_dep
            and dep_source in local_dep) or rmv_type == "upgrade":
        remove_action(source, rmv_type, "")
    elif len(local_dep) > 0 and not "" in local_dep:
        text.text_formatting(
            _("Following suprapackages requires ") + source +
            _(" suprapackage"), 0, 'info')
        for i in search.local_dependency(source, " "):
            if not i == "" and not i == dep_source:
                text.text_formatting(i + " ==> " + get_description(i), 1,
                                     'info')
        if rmv_type != "skip":
            sys.exit(1)
        else:
            text.text_formatting(
                _("Skipping removing ") + source +
                _(" suprapackage and continue remove process"), 0, 'warning')
    else:
        remove_action(source, rmv_type, "")
示例#5
0
def execute(command):
    text.text_formatting("-> executing " + command + " in the shell", 1, 'info')
    retri = command
    """ Better error handling is required, check out lpms code """
    stdout = subprocess.PIPE; stderr=subprocess.PIPE
    result = subprocess.Popen(command, shell=True, stdout=stdout, stderr=stderr)
    output, err = result.communicate()
    return result.returncode
示例#6
0
文件: search.py 项目: lonicera/Peynir
def local_search(source):
    """Search suprapackage in local"""
    dirlist = os.listdir(cons.sprpckg_dir)
    counter = 0
    for fname in dirlist:
        if source == "" or source == "all":
            text.text_formatting(fname[:-4] + " ==> " + functions.get_description(fname[:-4]),1,'info')  
        elif similarity(fname[:-4],source) > 0.45 and len(dirlist) >0:
            text.text_formatting(fname[:-4] + " ==> " + functions.get_description(fname[:-4]),1, 'info')
示例#7
0
def pacman(package,action):
    text.text_formatting("-> " + action.strip("e") + "ing " + package + " via pacman", 1, 'info') #remove, removing eksikliğini düzelt
    if ' '.join(package_check(package)[1]):
          text.text_formatting(_("-> Following package(s) not found in pacman repository, so skipped " + ' '.join(package_check(package)[1])), 1, 'error')
    if action == "install":
       retri = "pacman -S --noconfirm "+ ' '.join(package_check(package)[0])
    elif action == "remove":
       retri = "pacman -Rs --noconfirm "+ ' '.join(package_check(package)[0])
    devnull = open('/dev/null', 'w')
    subprocess.Popen(retri, shell=True, stdout=devnull).wait()
示例#8
0
def rmv_local_dependencies(source):
    root = functions.get_root(cons.sprpckg_dir+source+".xml")
    dependcount = len(root[2])
    dependencies = root[2]
    if dependcount > 0:
        for dep in dependencies:
            if os.path.isfile(cons.sprpckg_dir + dep.text +".xml"):
                mdfy.modify_rmv(cons.sprpckg_dir + dep.text +".xml","<Dependencies ",""," " + source,"next","",4)
            else:
                text.text_formatting(_("There is no file to remove local dependencies"), 1, 'warning')
示例#9
0
def local_search(source):
    """Search suprapackage in local"""
    dirlist = os.listdir(cons.sprpckg_dir)
    counter = 0
    for fname in dirlist:
        if source == "" or source == "all":
            text.text_formatting(
                fname[:-4] + " ==> " + functions.get_description(fname[:-4]),
                1, 'info')
        elif similarity(fname[:-4], source) > 0.45 and len(dirlist) > 0:
            text.text_formatting(
                fname[:-4] + " ==> " + functions.get_description(fname[:-4]),
                1, 'info')
示例#10
0
def execute(command):
    text.text_formatting("-> executing " + command + " in the shell", 1,
                         'info')
    retri = command
    """ Better error handling is required, check out lpms code """
    stdout = subprocess.PIPE
    stderr = subprocess.PIPE
    result = subprocess.Popen(command,
                              shell=True,
                              stdout=stdout,
                              stderr=stderr)
    output, err = result.communicate()
    return result.returncode
示例#11
0
def uptodate(xml_source,type_file,pacman):
    if type_file == "web":
       try:
           tree = etree.parse(urllib.request.urlopen(xml_source))
           if pacman == 1:
               text.text_formatting(_("-> Peynir also updating pacman repositories"), 1, 'info')
               devnull = open('/dev/null', 'w')
               try:
                   subprocess.Popen("pacman -Sy --noconfirm ", shell=True, stdout=devnull).wait()
               except:
                   text.text_formatting(_("There is a problem with pacman sync repository, If you continue to upgrade, you can get some error"), 1, 'warning') 
       except:
           text.text_formatting(_("Database couldn't updated."), 0, 'error')
           sys.exit(1)
    else:
        try:
            tree = etree.parse(xml_source)
        except:
            text.text_formatting(_("There is a problem with xml file"), 0, 'error')
            sys.exit(1)
            
    root = tree.getroot()
    find_node = root[0].findall('Last_update')
    up_date = find_node[0].text
    return up_date
示例#12
0
def rmv_local_dependencies(source):
    root = functions.get_root(cons.sprpckg_dir + source + ".xml")
    dependcount = len(root[2])
    dependencies = root[2]
    if dependcount > 0:
        for dep in dependencies:
            if os.path.isfile(cons.sprpckg_dir + dep.text + ".xml"):
                mdfy.modify_rmv(cons.sprpckg_dir + dep.text + ".xml",
                                "<Dependencies ", "", " " + source, "next", "",
                                4)
            else:
                text.text_formatting(
                    _("There is no file to remove local dependencies"), 1,
                    'warning')
示例#13
0
def pacman(package, action):
    text.text_formatting("-> " + action.strip("e") + "ing " + package +
                         " via pacman", 1,
                         'info')  #remove, removing eksikliğini düzelt
    if ' '.join(package_check(package)[1]):
        text.text_formatting(
            _("-> Following package(s) not found in pacman repository, so skipped "
              + ' '.join(package_check(package)[1])), 1, 'error')
    if action == "install":
        retri = "pacman -S --noconfirm " + ' '.join(package_check(package)[0])
    elif action == "remove":
        retri = "pacman -Rs --noconfirm " + ' '.join(package_check(package)[0])
    devnull = open('/dev/null', 'w')
    subprocess.Popen(retri, shell=True, stdout=devnull).wait()
示例#14
0
def uptodate(xml_source, type_file, pacman):
    if type_file == "web":
        try:
            tree = etree.parse(urllib.request.urlopen(xml_source))
            if pacman == 1:
                text.text_formatting(
                    _("-> Peynir also updating pacman repositories"), 1,
                    'info')
                devnull = open('/dev/null', 'w')
                try:
                    subprocess.Popen("pacman -Sy --noconfirm ",
                                     shell=True,
                                     stdout=devnull).wait()
                except:
                    text.text_formatting(
                        _("There is a problem with pacman sync repository, If you continue to upgrade, you can get some error"
                          ), 1, 'warning')
        except:
            text.text_formatting(_("Database couldn't updated."), 0, 'error')
            sys.exit(1)
    else:
        try:
            tree = etree.parse(xml_source)
        except:
            text.text_formatting(_("There is a problem with xml file"), 0,
                                 'error')
            sys.exit(1)

    root = tree.getroot()
    find_node = root[0].findall('Last_update')
    up_date = find_node[0].text
    return up_date
示例#15
0
def retrieve(place,url,file):
    status = "false"
    os.chdir(place)
    try:
        req=urllib.request.Request(url)
        req.add_header("User-Agent","Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/525.13 (KHTML,     like Gecko) Chrome/0.2.149.29 Safari/525.13")
        usock = urllib.request.urlopen(req)
        data = usock.read()
        usock.close()
        urllib.request.urlcleanup() 
    except:
        text.text_formatting(file + _(" could not retrivied from mirror"), 0, 'error')
        sys.exit(1)

    fp = open(file, 'wb')
    fp.write(data)
    fp.close()
示例#16
0
def sync_repo(pacman):
    text.text_formatting(_(">> Local database synchronizing with server"), 0, 'info')
    if not os.path.isfile(cons.db_dir+cons.db_file) or uptodate(cons.db_dir+cons.db_file,"local",pacman) != uptodate(cons.mirror+cons.db_file,"web",pacman):
       try:
           retrieve(cons.db_dir,cons.mirror+cons.db_file,cons.db_dir+cons.db_file)
           text.text_formatting(_("Database successfully updated."), 0, 'info')
       except:
           text.text_formatting(_("Database couldn't updated."), 0, 'error')
           sys.exit(1)
    else:
       text.text_formatting(_("Database already updated."), 0, 'info')
示例#17
0
def retrieve(place, url, file):
    status = "false"
    os.chdir(place)
    try:
        req = urllib.request.Request(url)
        req.add_header(
            "User-Agent",
            "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/525.13 (KHTML,     like Gecko) Chrome/0.2.149.29 Safari/525.13"
        )
        usock = urllib.request.urlopen(req)
        data = usock.read()
        usock.close()
        urllib.request.urlcleanup()
    except:
        text.text_formatting(file + _(" could not retrivied from mirror"), 0,
                             'error')
        sys.exit(1)

    fp = open(file, 'wb')
    fp.write(data)
    fp.close()
示例#18
0
def remove(source, rmv_type, dep_source):
    if not suprapackage_check(source):
        text.text_formatting(_("This suprapackage is not installed."), 0,  'error')
        sys.exit(1)
    text.text_formatting(">> " + source + _(" suprapackage is removing"), 0, 'info')
    if rmv_type == "complete":
       relationship.dependencies(source,"remove")
    local_dep = search.local_dependency(source," ")
    
    if (len(local_dep) == 1 and not "" in local_dep and dep_source in local_dep) or rmv_type == "upgrade":
        remove_action(source, rmv_type, "")           
    elif len(local_dep) > 0 and not "" in local_dep:
       text.text_formatting(_("Following suprapackages requires ") + source + _(" suprapackage"), 0, 'info')
       for i in search.local_dependency(source," "):
           if not i == "" and not i == dep_source:
              text.text_formatting(i + " ==> " + get_description(i), 1, 'info')
       if rmv_type != "skip":
           sys.exit(1)
       else:
           text.text_formatting(_("Skipping removing ") + source + _(" suprapackage and continue remove process"), 0, 'warning') 
    else:
        remove_action(source, rmv_type, "")
示例#19
0
def sync_repo(pacman):
    text.text_formatting(_(">> Local database synchronizing with server"), 0,
                         'info')
    if not os.path.isfile(cons.db_dir + cons.db_file) or uptodate(
            cons.db_dir + cons.db_file, "local", pacman) != uptodate(
                cons.mirror + cons.db_file, "web", pacman):
        try:
            retrieve(cons.db_dir, cons.mirror + cons.db_file,
                     cons.db_dir + cons.db_file)
            text.text_formatting(_("Database successfully updated."), 0,
                                 'info')
        except:
            text.text_formatting(_("Database couldn't updated."), 0, 'error')
            sys.exit(1)
    else:
        text.text_formatting(_("Database already updated."), 0, 'info')
示例#20
0
def modify_rmv(tar_file, srch, indicator, action, place, rplc, indent):
    """Functions for removing string from file"""
    a = get_prop(tar_file)
    text.text_formatting("-> removing " + action + " from " + tar_file, 1,
                         'info')
    try:
        with open(tar_file) as fin, NamedTemporaryFile(dir='.',
                                                       delete=False) as fout:
            counter = 0
            for line in fin:
                if place == "first" and counter == 0:
                    line = line.replace(action, rplc)
                elif srch in line:
                    position = line.find(indicator)
                    if place == "previous":
                        line = line[:position].replace(
                            action, rplc).strip() + line[position:]
                    elif place == "next":
                        if indent > 0:
                            tabs = " "
                            line = line[:position] + line[position:].replace(
                                action, rplc)
                            for i in range(indent):
                                line = tabs + line
                        else:
                            line = line[:position] + line[position:].replace(
                                action, rplc)
                if place == "after" or place == "before":
                    if action in line:
                        line = ""
                fout.write(line.encode('utf8'))
                counter = counter + 1
            os.rename(fout.name, tar_file)
            set_prop(tar_file, a)
    except:
        text.text_formatting(_("Couldn't found target file"), 1, 'error')
示例#21
0
文件: search.py 项目: lonicera/Peynir
def srch_pynr(srch,node,action):
    """Search suprapackage in repository"""
    repo_root = functions.get_root(cons.repo)
    repo_search = repo_root[1].findall(node)
    if srch == "all":
        text.text_formatting(str(len(repo_root[1])) + " suprapackages have found.", 0, 'info')
        for rep in repo_root[1]:
            text.text_formatting(rep[0].text + " ==> " + functions.get_description(rep[0].text), 1, 'info')
    else:
        for comp in range(len(repo_search)):
            if action == "find":
                if similarity(str(repo_search[comp].text),str(srch)) > 0.45 and int(len(repo_search)) >0:
                    text.text_formatting(_("-> Found ") + repo_search[comp].text + _(" similarity is ") + str(similarity(str(repo_search[comp].text),str(srch))*100)+"%", 1, 'info')
            if repo_search[comp].text == srch and action == "absolute":
                return True
                break
示例#22
0
def srch_pynr(srch, node, action):
    """Search suprapackage in repository"""
    repo_root = functions.get_root(cons.repo)
    repo_search = repo_root[1].findall(node)
    if srch == "all":
        text.text_formatting(
            str(len(repo_root[1])) + " suprapackages have found.", 0, 'info')
        for rep in repo_root[1]:
            text.text_formatting(
                rep[0].text + " ==> " + functions.get_description(rep[0].text),
                1, 'info')
    else:
        for comp in range(len(repo_search)):
            if action == "find":
                if similarity(str(repo_search[comp].text),
                              str(srch)) > 0.45 and int(len(repo_search)) > 0:
                    text.text_formatting(
                        _("-> Found ") + repo_search[comp].text +
                        _(" similarity is ") + str(
                            similarity(str(repo_search[comp].text), str(srch))
                            * 100) + "%", 1, 'info')
            if repo_search[comp].text == srch and action == "absolute":
                return True
                break
示例#23
0
def upgrade():
    dirlist=os.listdir(cons.sprpckg_dir)
    counter = 0
    up_list = []
    for fname in dirlist:
       if fname[-3:] == "xml" and upcontrol(fname[:-4],"local") != upcontrol(fname[:-4],"repo") and search.srch_pynr(fname[:-4],'Peynir/Name','find'):
           up_list.append(fname[:-4]);
           counter = counter + 1
    if len(up_list) == 0:
        text.text_formatting(_("There is nothing to do"), 0, 'info')
    else:
        text.text_formatting(_("Following suprapackage(s) will upgrade"), 0, 'info')
        for up in up_list[0:]:
            text.text_formatting(up + " ==> " + get_description(up), 1, 'info')
        devnull = open('/dev/null', 'w')
        try:
            text.text_formatting(_("-> Peynir first upgrade your system via pacman"), 1, 'info')
            subprocess.Popen("pacman -Su --noconfirm ", shell=True, stdout=devnull).wait()
        except:
            text.text_formatting(_("There is a problem with upgrade the system via pacman, If you continue to upgrade, I can get some error"), 1, 'warning')
        for up in up_list[0:]:
            text.text_formatting(up + _(" suprapackage is upgrading ..."), 0, 'info')
            #answer ı nasıl aktaracağız bakalım ???
            try:
                text.text_formatting(_("-> Retrieve updated suprapackage from server"), 1, 'info')
                retrieve(cons.sprpckg_dir,cons.mirror + up +".xml",cons.sprpckg_dir + up + "_bck" +".xml")
            except:
                text.text_formatting(_("-> There is a problem with getting updated suprapackage from server"), 1, 'error')
            try:
                tree = etree.parse(cons.sprpckg_dir + up +".xml")
                root = tree.getroot()
                local_dep = root[2].attrib['local']
                text.text_formatting(_("-> Transision local dependencies from old one to updated one"), 1, 'info')
                mdfy.modify_add(cons.sprpckg_dir + up + "_bck"+".xml","<Dependencies","'>"," " + local_dep,"previous")
            except:
                text.text_formatting(_("-> Error from transision local dependencies"), 0, 'error')             
            remove(up,"upgrade","")
            shutil.move(cons.sprpckg_dir + up + "_bck"+".xml", cons.sprpckg_dir + up + ".xml")
            install(up + ".xml","local","")
示例#24
0
def install(source, place, adress):
    if suprapackage_check(source) and not place == "local":
        text.text_formatting(_(">> This suprapackage already installed."), 0,
                             'error')
        sys.exit(1)

    if place == "local":
        try:
            if adress != "":
                tree = etree.parse(adress + "/" + source)
                cp_adress = adress + "/" + source
            else:
                tree = etree.parse(os.getcwd() + "/" + source)
                cp_adress = ""
            if not os.path.isfile(cons.sprpckg_dir + "/" + source):
                shutil.copyfile(cp_adress, cons.sprpckg_dir + "/" + source)
            position = source.find('.')
            source = source[:position]
        except:
            text.text_formatting(
                "Suprapackage source couldn't find, check suprapackege path",
                0, 'error')
            sys.exit(0)
    else:
        if cons.cachedir is None or (
                not cons.cachedir is None
                and not os.path.isfile(cons.cachedir + "/" + source + ".xml")):
            if not cons.cachedir is None and not os.path.isfile(cons.cachedir +
                                                                "/" + source):
                text.text_formatting(
                    _(source +
                      " couldn't found in cache directory so trying to retrive from server"
                      ), 1, 'warning')
            retrieve(cons.sprpckg_dir, cons.mirror + source + ".xml",
                     cons.sprpckg_dir + source + ".xml")

            tree = etree.parse(cons.sprpckg_dir + source + ".xml")
        else:
            shutil.copyfile(cons.cachedir + source + ".xml",
                            cons.sprpckg_dir + "/" + source + ".xml")
    tree = etree.parse(cons.sprpckg_dir + source + ".xml")
    text.text_formatting(">> " + source + _(" suprapackage is installing"), 0,
                         'info')
    relationship.conflicts(source)
    relationship.dependencies(source, "")
    root = tree.getroot()
    steps = len(root[3])
    text.text_formatting(str(steps) + _(" step(s) will executed."), 0, 'info')
    counter = 1
    for step in root[3]:
        action_type = step.attrib["type"]
        text.text_formatting(
            "==> Step " + str(counter) + " of " + str(steps) + " is executing",
            0, 'info')
        #Alttaki kodu type 4 de de kullanıldığından fonksiyon haline gelse iyi olacak
        try:
            if action_type == "1":
                package = step.text
                if "question" in step.attrib:
                    package = question_mark(step.attrib["question"], package,
                                            source, "install")
                pac_action = step.attrib["action"]
                pacman(package, pac_action)
            elif action_type == "2":
                mdfy_type = step.attrib["modify"]
                source1 = step.attrib["source"]
                indicator = step.attrib["indicator"]
                search = step.attrib["search"]
                action = step.text
                place = step.attrib["place"]
                if "question" in step.attrib:
                    action = question_mark(step.attrib["question"], action,
                                           source, "install")
                if mdfy_type == "add":
                    mdfy.modify_add(source1, search, indicator, action, place)
                else:
                    mdfy.modify_rmv(source1, search, indicator, action, place,
                                    " ", 0)
            elif action_type == "3":
                command = step.text
                if "question" in step.attrib:
                    command = question_mark(step.attrib["question"], command,
                                            source, "install")

                if execute(command) != 0:
                    text.text_formatting(
                        _("Error ") + step +
                        _(", so the installation of suprapackge will be reverted "
                          ), 0, 'error')
                    remove_action(source, "complete", step)
                    break
            counter = counter + 1
        except:
            text.text_formatting(
                _("Error occureed in step of ") + step, 0, 'error')
            sys.exit(1)
示例#25
0
def install(source, place, adress):
    if suprapackage_check(source) and not place == "local":
        text.text_formatting(_(">> This suprapackage already installed."), 0, 'error')
        sys.exit(1)
    
    if place == "local":
        try:
            if adress != "":
                tree = etree.parse(adress+"/"+source)
                cp_adress = adress+"/"+source
            else:
                tree = etree.parse(os.getcwd()+"/"+source)
                cp_adress = ""
            if not os.path.isfile(cons.sprpckg_dir+"/"+source):
                shutil.copyfile(cp_adress, cons.sprpckg_dir+"/"+source)
            position = source.find('.')
            source = source[:position]
        except:
            text.text_formatting("Suprapackage source couldn't find, check suprapackege path", 0, 'error')
            sys.exit(0)
    else:
        if cons.cachedir is None or (not cons.cachedir is None and not os.path.isfile(cons.cachedir+"/"+source + ".xml")):
            if not cons.cachedir is None and not os.path.isfile(cons.cachedir+"/"+source):
                text.text_formatting(_(source + " couldn't found in cache directory so trying to retrive from server"), 1, 'warning')
            retrieve(cons.sprpckg_dir,cons.mirror+source+".xml",cons.sprpckg_dir+source+".xml")
            
            tree = etree.parse(cons.sprpckg_dir+source+".xml")
        else:
            shutil.copyfile(cons.cachedir+source+".xml", cons.sprpckg_dir+"/"+source+".xml")
    tree = etree.parse(cons.sprpckg_dir+source+".xml")
    text.text_formatting(">> " + source + _(" suprapackage is installing"), 0, 'info')
    relationship.conflicts(source)
    relationship.dependencies(source,"")
    root = tree.getroot()
    steps = len(root[3])
    text.text_formatting(str(steps) + _(" step(s) will executed."), 0, 'info')
    counter = 1
    for step in root[3]:
       action_type = step.attrib["type"]
       text.text_formatting("==> Step " + str(counter)+ " of " + str(steps) + " is executing", 0, 'info')
       #Alttaki kodu type 4 de de kullanıldığından fonksiyon haline gelse iyi olacak
       try:
           if action_type == "1":
               package = step.text
               if "question" in step.attrib:
                   package = question_mark(step.attrib["question"], package, source, "install")
               pac_action = step.attrib["action"]
               pacman(package,pac_action)
           elif action_type == "2":
               mdfy_type = step.attrib["modify"]
               source1 = step.attrib["source"]
               indicator = step.attrib["indicator"]
               search = step.attrib["search"]
               action = step.text
               place = step.attrib["place"]
               if "question" in step.attrib:
                   action = question_mark(step.attrib["question"], action, source, "install")
               if mdfy_type == "add":
                   mdfy.modify_add(source1,search,indicator,action,place)
               else:
                   mdfy.modify_rmv(source1,search,indicator,action,place, " ",0) 
           elif action_type == "3":
               command = step.text
               if "question" in step.attrib:
                   command = question_mark(step.attrib["question"], command, source, "install")

               if execute(command) != 0:
                   text.text_formatting(_("Error ") + step + _(", so the installation of suprapackge will be reverted ") , 0, 'error')
                   remove_action(source, "complete", step)
                   break
           counter = counter + 1
       except:
           text.text_formatting(_("Error occureed in step of ") + step, 0, 'error')
           sys.exit(1)
示例#26
0
def conflicts(source):
    root = functions.get_root(cons.sprpckg_dir+source+".xml")
    """ Resolving conflicts """
    text.text_formatting(_(">> Check for conflicts..."), 0, 'info')
    conflictcount = len(root[1])
    conflicts = root[1]
    if conflictcount > 0:
        text.text_formatting(str(conflictcount) + _(" conflicts have found."), 1, 'info')
        text.text_formatting(_("Following suprapackage(s) will remove. "), 0, 'info')
        for conf in root[1]:
            try:
                text.text_formatting(conf.text + " ==> " + get.description(conf.text), 1, '')
            except:
                text.text_formatting(conf.text + _(" ==> There is no description for this suprapackage"), 1, 'warning')
        if os.path.isfile(cons.sprpckg_dir + conf.text + ".xml"):
            answer = input(_("Are you want to remove these suprapackages (Y/N): ")) 
            answer.upper()
        elif cons.confm:
            answer = _("Y")
        else:
            answer = _("Y")
        
        if answer == _("Y"):
            for conf in root[1]:
                package = conf.text
                if suprapackage_check(package):
                    remove(package,"","")
                else:
                    text.text_formatting(package + _(" is not installed"), 0, 'warning')
        else:
            text.text_formatting(package + _("Suprapackage couldn't installed."), 0, 'error')
            sys.exit(1)
    else:
        text.text_formatting(_("There is a no conflict"), 1, 'info')
示例#27
0
def upgrade():
    dirlist = os.listdir(cons.sprpckg_dir)
    counter = 0
    up_list = []
    for fname in dirlist:
        if fname[-3:] == "xml" and upcontrol(fname[:-4], "local") != upcontrol(
                fname[:-4], "repo") and search.srch_pynr(
                    fname[:-4], 'Peynir/Name', 'find'):
            up_list.append(fname[:-4])
            counter = counter + 1
    if len(up_list) == 0:
        text.text_formatting(_("There is nothing to do"), 0, 'info')
    else:
        text.text_formatting(_("Following suprapackage(s) will upgrade"), 0,
                             'info')
        for up in up_list[0:]:
            text.text_formatting(up + " ==> " + get_description(up), 1, 'info')
        devnull = open('/dev/null', 'w')
        try:
            text.text_formatting(
                _("-> Peynir first upgrade your system via pacman"), 1, 'info')
            subprocess.Popen("pacman -Su --noconfirm ",
                             shell=True,
                             stdout=devnull).wait()
        except:
            text.text_formatting(
                _("There is a problem with upgrade the system via pacman, If you continue to upgrade, I can get some error"
                  ), 1, 'warning')
        for up in up_list[0:]:
            text.text_formatting(up + _(" suprapackage is upgrading ..."), 0,
                                 'info')
            #answer ı nasıl aktaracağız bakalım ???
            try:
                text.text_formatting(
                    _("-> Retrieve updated suprapackage from server"), 1,
                    'info')
                retrieve(cons.sprpckg_dir, cons.mirror + up + ".xml",
                         cons.sprpckg_dir + up + "_bck" + ".xml")
            except:
                text.text_formatting(
                    _("-> There is a problem with getting updated suprapackage from server"
                      ), 1, 'error')
            try:
                tree = etree.parse(cons.sprpckg_dir + up + ".xml")
                root = tree.getroot()
                local_dep = root[2].attrib['local']
                text.text_formatting(
                    _("-> Transision local dependencies from old one to updated one"
                      ), 1, 'info')
                mdfy.modify_add(cons.sprpckg_dir + up + "_bck" + ".xml",
                                "<Dependencies", "'>", " " + local_dep,
                                "previous")
            except:
                text.text_formatting(
                    _("-> Error from transision local dependencies"), 0,
                    'error')
            remove(up, "upgrade", "")
            shutil.move(cons.sprpckg_dir + up + "_bck" + ".xml",
                        cons.sprpckg_dir + up + ".xml")
            install(up + ".xml", "local", "")
示例#28
0
def remove_action(source, rmv_type, access_point):        
    relationship.rmv_local_dependencies(source)
    try:
        tree = etree.parse(cons.sprpckg_dir+source+".xml")
        os.remove(cons.sprpckg_dir+source+".xml")
    except:
        text.text_formatting(_("Local suprapackage couldn't found"), 0, 'error')
        sys.exit(1)
    root = tree.getroot()
    steps = len(root[3])
    counter = 1
    if access_point == "":
        access_point = root[3]
        
    for step in reversed(access_point):
       action_type = step.attrib["type"]
       try:
           remove_tag = step.attrib["remove_tag"]
       except KeyError:
           remove_tag = " "
       text.text_formatting("==> Step " + str(counter)+ " of " + str(steps) + " is executing", 0, 'info')
       try:
           if action_type == "1":
               if remove_tag == "skip":
                   text.text_formatting(_("-> Skipping this step for remove action"), 1, 'info')
               else:
                   package = step.text
                   if "question" in step.attrib:
                       package = question_mark(step.attrib["answer"], package, "", "remove") 
                   pacman(package,"remove")
           elif action_type == "2":
               if remove_tag == "skip":
                   text.text_formatting(_("-> Skipping this step for remove action"), 1, 'info')
               else:
                   mdfy_type = step.attrib["modify"]
                   if mdfy_type == "add":
                       mdfy_type = "remove"
                   elif mdfy_type == "remove":
                       mdfy_type = "add"
                   source = step.attrib["source"]
                   indicator = step.attrib["indicator"]
                   search = step.attrib["search"]
                   action = convert(step.text)
                   place = step.attrib["place"]
                   if "question" in step.attrib:
                       action = question_mark(step.attrib["answer"], action, "", "remove")
                   if mdfy_type == "add":
                       mdfy.modify_add(source,search,indicator,action,place)
                   else:
                       mdfy.modify_rmv(source,search,indicator,action,place, "",0) 
           elif action_type == "3" and remove_tag != "skip":
               if remove_tag == "skip":
                   text.text_formatting(_("-> Skipping this step for remove action"), 1, 'info')
               else:
                   try:
                       reverse = step.attrib["reverse"]
                       if "question" in step.attrib:
                           reverse = question_mark(step.attrib["answer"], action, "", "remove")
                       execute(reverse)
                   except:
                       text.text_formatting(_("There is no defined action for this step"), 1, 'warning')
           counter = counter + 1
       except:
           text.text_formatting(_("Error occured when remove suprapackage"), 0, 'error') #bu ne bu, bu ne, ne hatası bu :)
           sys.exit(1)
示例#29
0
def dependencies(source, action):
    text.text_formatting(_(">> Resolving dependencies.."), 0, 'info')
    root = functions.get_root(cons.sprpckg_dir + source + ".xml")
    #Bağımlılıklar çözülüyor
    dependcount = len(root[2])
    dependencies = root[2]
    if dependcount > 0:
        text.text_formatting(
            str(dependcount) + _(" dependencies have found."), 1, 'info')
        #Tamamen kaldırma işlemi için ....
        if action == "remove":
            text.text_formatting(_("Following suprapackage(s) will remove. "),
                                 1, 'info')
            for dep in root[2]:
                try:
                    text.text_formatting(
                        dep.text + " ==> " + get_description(dep.text), 1,
                        'info')
                except:
                    text.text_formatting(
                        dep.text +
                        _(" ==> There is no description for this suprapackage"
                          ), 1, 'warning')
            if cons.confm:
                answer = _("Y")
            else:
                answer = input(
                    _("Are you want to remove these suprapackages (Y/N): "))
                answer = answer.upper()
            if answer == _("Y"):
                for dep in root[2]:
                    package = dep.text
                    functions.remove(package, "skip", source)
            else:
                text.text_formatting(
                    _("Dependencies coulnd't removed so remove process couldn't continue."
                      ), 0, 'error')
                sys.exit(1)
        else:
            text.text_formatting(_("Following suprapackage(s) will install. "),
                                 0, 'info')
            for dep in root[2]:
                if not search.srch_pynr(dep.text, 'Peynir/Name',
                                        'absolute') and not suprapackage_check(
                                            str(dep.text)):
                    text.text_formatting(
                        dep.text +
                        _(" couldn't found in repository, you can install it manually"
                          ), 1, 'warning')
                    os.remove(cons.sprpckg_dir + source + ".xml")
                    sys.exit(1)
                else:
                    try:
                        text.text_formatting(
                            dep.text + " ==> " + get_description(dep.text), 1,
                            'info')
                    except:
                        text.text_formatting(
                            dep.text +
                            _(" ==> There is no description for this suprapackage"
                              ), 1, 'info')
            if cons.confm:
                answer = _("Y")
            else:
                answer = input(
                    _("Are you want to install these suprapackages (Y/N): "))
                answer = answer.upper()
            if answer == _("Y"):
                for dep in root[2]:
                    package = dep.text
                    if not functions.suprapackage_check(package):
                        functions.install(
                            package, "", ""
                        )  #İç içe bağımlılık sorunu olacak o neden ilave bir fonksiyon paramatresi ise bu soruyu bir kez sordurulabilir
                    else:
                        text.text_formatting(
                            ">> " + package + _(" is already installed"), 0,
                            'info')
                    mdfy.modify_add(cons.sprpckg_dir + package + ".xml",
                                    "<Dependencies", "'>", " " + source,
                                    "previous")
            else:
                os.remove(cons.sprpckg_dir + source + ".xml")
                text.text_formatting(
                    _("Dependencies coulnd't installed so install process couldn't continue."
                      ), 0, 'error')
                sys.exit(1)
    else:
        text.text_formatting(_("There is a no dependencies"), 1, 'info')
示例#30
0
def conflicts(source):
    root = functions.get_root(cons.sprpckg_dir + source + ".xml")
    """ Resolving conflicts """
    text.text_formatting(_(">> Check for conflicts..."), 0, 'info')
    conflictcount = len(root[1])
    conflicts = root[1]
    if conflictcount > 0:
        text.text_formatting(
            str(conflictcount) + _(" conflicts have found."), 1, 'info')
        text.text_formatting(_("Following suprapackage(s) will remove. "), 0,
                             'info')
        for conf in root[1]:
            try:
                text.text_formatting(
                    conf.text + " ==> " + get.description(conf.text), 1, '')
            except:
                text.text_formatting(
                    conf.text +
                    _(" ==> There is no description for this suprapackage"), 1,
                    'warning')
        if os.path.isfile(cons.sprpckg_dir + conf.text + ".xml"):
            answer = input(
                _("Are you want to remove these suprapackages (Y/N): "))
            answer.upper()
        elif cons.confm:
            answer = _("Y")
        else:
            answer = _("Y")

        if answer == _("Y"):
            for conf in root[1]:
                package = conf.text
                if suprapackage_check(package):
                    remove(package, "", "")
                else:
                    text.text_formatting(package + _(" is not installed"), 0,
                                         'warning')
        else:
            text.text_formatting(
                package + _("Suprapackage couldn't installed."), 0, 'error')
            sys.exit(1)
    else:
        text.text_formatting(_("There is a no conflict"), 1, 'info')
示例#31
0
def db_file_check():
    if not os.path.isfile(cons.log_file):
        logging.basicConfig(filename=cons.log_file,
                            format='%(asctime)s:%(levelname)s:%(message)s',
                            datefmt='%m/%d/%Y %I:%M:%S %p',
                            level=logging.DEBUG)
        text.text_formatting(_("Log file created"), 0, 'warning')
    if not os.path.isfile(cons.db_dir + cons.db_file):
        try:
            text.text_formatting(
                _("Database could'nt found. Getting from server"), 0,
                'warning')
            if not os.path.isdir(cons.db_dir):
                try:
                    text.text_formatting(_("Database folder is creating..."),
                                         0, 'info')
                    os.makedirs(cons.db_dir)
                    os.makedirs(cons.sprpckg_dir)
                except:
                    text.text_formatting(_("Database dir couldn't create"), 0,
                                         'error')
            retrieve(cons.db_dir, cons.mirror + cons.db_file,
                     cons.db_dir + cons.db_file)
            text.text_formatting(_("Database successfully updated."), 0,
                                 'debug')
        except:
            text.text_formatting(_("Database couldn't updated."), 0, 'error')
            sys.exit(1)
示例#32
0
def main():
    if not os.geteuid() == 0:
        sys.exit(
            _("You must be root to run this application, please use sudo and try again."
              ))
    functions.db_file_check()
    parser = argparse.ArgumentParser(
        description=
        '''Suprapackage Manager for Archlinux. It's also a framework for configuring Archlinux or other pacman based distribution.''',
        prog='peynir')
    parser.add_argument(
        "-d",
        "--debug",
        help="Log everyhing (including info, warning and errors)",
        action="store_true")
    parser.add_argument("-S",
                        nargs='*',
                        metavar='Suprapackage',
                        help="Install suprapackage")
    parser.add_argument("-U",
                        metavar='Suprapackage',
                        help="Install local suprapackage")
    parser.add_argument("-R",
                        nargs='*',
                        metavar='Suprapackage',
                        help="Remove suprapackage")
    parser.add_argument("-Rs",
                        nargs='*',
                        metavar='Suprapackage',
                        help="Remove suprapackage and its dependencies")
    parser.add_argument("-Sy", help="Update repository", action="store_true")
    parser.add_argument("-Syy",
                        help="Update peynir and pacman repository",
                        action="store_true")
    parser.add_argument("-Su", help="Upgrade the system", action="store_true")
    parser.add_argument("-Syu", help="Upgrade the system", action="store_true")
    parser.add_argument("-Ss", help="Search suprapackege in repository")
    parser.add_argument("-Qs", help="Search suprapackege in local")
    parser.add_argument(
        "-O", help="Repair system or package (not fully implemented)")
    parser.add_argument("--noconfirm",
                        help="Do not prompt for any confirmation",
                        action="store_true")
    parser.add_argument(
        "--cachedir",
        help=
        "[path] Overrides the default location of the suprapackage cache directory."
    )
    parser.add_argument("--silence", help="No output", action="store_true")

    args = parser.parse_args()

    if len(sys.argv) == 1:
        parser.print_help()
        sys.exit(1)
    if args.noconfirm:
        cons.confm = True
    if args.debug:
        cons.debug = True
    if args.silence:
        cons.silence = True
    if args.cachedir:
        cons.cachedir = args.cachedir.strip()
        if not cons.cachedir[len(cons.cachedir) - 1:len(cons.cachedir)] == "/":
            cons.cachedir = cons.cachedir + "/"
            print(cons.cachedir)

    if args.Sy:
        functions.sync_repo(0)
    if args.Syy:
        functions.sync_repo(1)
    if args.Su:
        functions.upgrade()
    if args.Syu:
        functions.sync_repo(1)
        functions.upgrade()
    if args.S:
        functions.db_file_check(
        )  #Burada ve diğer gereksiz kullanımları temizle
        for i in args.S:
            rqst = i.lower()
            if search.srch_pynr(rqst, 'Peynir/Name', 'absolute'):
                functions.install(rqst, "", "")
            else:
                text.text_formatting(
                    'error: ' + rqst + ' no such a suprapackage', 0, "warning")

    if args.R:
        functions.db_file_check()
        for i in args.R:
            rqst = i.lower()
            functions.remove(rqst, "", "")
    if args.Rs:
        functions.db_file_check()
        for i in args.Rs:
            rqst = i.lower()
            functions.remove(rqst, "complete", "")
    if args.Ss:
        functions.db_file_check()
        for i in args.Ss.split():
            rqst = i.lower()
            text.text_formatting("Results for " + rqst, 0, 'info')
            search.srch_pynr(rqst, 'Peynir/Name', 'find')
    if args.Qs:
        functions.db_file_check()
        for i in args.Qs.split():
            rqst = i.lower()
            text.text_formatting("Results for " + rqst, 0, 'info')
            search.local_search(rqst)
    if args.U:
        functions.db_file_check()
        if "/" in args.U:
            position = args.U.rfind('/')
            adress = args.U[:position]
            package = args.U[position + 1:]
        else:
            adress = ""
        if package[-3:] != "xml" and "." in package:
            text.text_formatting(_("Invalid package format"), 0, "error")
            sys.exit(1)
        elif not "." in package:
            package = package + ".xml"

        if not functions.suprapackage_check(package[:-4]):
            functions.install(package, "local", adress)
        else:
            text.text_formatting(
                _(">> This suprapackage already installed in your system."), 0,
                'error')
示例#33
0
def remove_action(source, rmv_type, access_point):
    relationship.rmv_local_dependencies(source)
    try:
        tree = etree.parse(cons.sprpckg_dir + source + ".xml")
        os.remove(cons.sprpckg_dir + source + ".xml")
    except:
        text.text_formatting(_("Local suprapackage couldn't found"), 0,
                             'error')
        sys.exit(1)
    root = tree.getroot()
    steps = len(root[3])
    counter = 1
    if access_point == "":
        access_point = root[3]

    for step in reversed(access_point):
        action_type = step.attrib["type"]
        try:
            remove_tag = step.attrib["remove_tag"]
        except KeyError:
            remove_tag = " "
        text.text_formatting(
            "==> Step " + str(counter) + " of " + str(steps) + " is executing",
            0, 'info')
        try:
            if action_type == "1":
                if remove_tag == "skip":
                    text.text_formatting(
                        _("-> Skipping this step for remove action"), 1,
                        'info')
                else:
                    package = step.text
                    if "question" in step.attrib:
                        package = question_mark(step.attrib["answer"], package,
                                                "", "remove")
                    pacman(package, "remove")
            elif action_type == "2":
                if remove_tag == "skip":
                    text.text_formatting(
                        _("-> Skipping this step for remove action"), 1,
                        'info')
                else:
                    mdfy_type = step.attrib["modify"]
                    if mdfy_type == "add":
                        mdfy_type = "remove"
                    elif mdfy_type == "remove":
                        mdfy_type = "add"
                    source = step.attrib["source"]
                    indicator = step.attrib["indicator"]
                    search = step.attrib["search"]
                    action = convert(step.text)
                    place = step.attrib["place"]
                    if "question" in step.attrib:
                        action = question_mark(step.attrib["answer"], action,
                                               "", "remove")
                    if mdfy_type == "add":
                        mdfy.modify_add(source, search, indicator, action,
                                        place)
                    else:
                        mdfy.modify_rmv(source, search, indicator, action,
                                        place, "", 0)
            elif action_type == "3" and remove_tag != "skip":
                if remove_tag == "skip":
                    text.text_formatting(
                        _("-> Skipping this step for remove action"), 1,
                        'info')
                else:
                    try:
                        reverse = step.attrib["reverse"]
                        if "question" in step.attrib:
                            reverse = question_mark(step.attrib["answer"],
                                                    action, "", "remove")
                        execute(reverse)
                    except:
                        text.text_formatting(
                            _("There is no defined action for this step"), 1,
                            'warning')
            counter = counter + 1
        except:
            text.text_formatting(_("Error occured when remove suprapackage"),
                                 0, 'error')  #bu ne bu, bu ne, ne hatası bu :)
            sys.exit(1)
示例#34
0
def db_file_check():
    if not os.path.isfile(cons.log_file):
        logging.basicConfig(filename=cons.log_file, format='%(asctime)s:%(levelname)s:%(message)s',  datefmt='%m/%d/%Y %I:%M:%S %p', level=logging.DEBUG)
        text.text_formatting(_("Log file created"), 0, 'warning')
    if not os.path.isfile(cons.db_dir+cons.db_file):
        try:
            text.text_formatting(_("Database could'nt found. Getting from server"), 0, 'warning')
            if not os.path.isdir(cons.db_dir):
                try:
                    text.text_formatting(_("Database folder is creating..."), 0, 'info')
                    os.makedirs(cons.db_dir)
                    os.makedirs(cons.sprpckg_dir)
                except:
                    text.text_formatting(_("Database dir couldn't create"), 0, 'error')
            retrieve(cons.db_dir,cons.mirror+cons.db_file,cons.db_dir+cons.db_file)
            text.text_formatting(_("Database successfully updated."), 0, 'debug')
        except:
            text.text_formatting(_("Database couldn't updated."), 0, 'error')
            sys.exit(1)
示例#35
0
def dependencies(source,action):
    text.text_formatting(_(">> Resolving dependencies.."), 0, 'info')
    root = functions.get_root(cons.sprpckg_dir+source+".xml")
    #Bağımlılıklar çözülüyor
    dependcount = len(root[2])
    dependencies = root[2]
    if dependcount > 0:
        text.text_formatting(str(dependcount) + _(" dependencies have found."), 1, 'info')
        #Tamamen kaldırma işlemi için ....
        if action == "remove":
            text.text_formatting(_("Following suprapackage(s) will remove. "), 1, 'info')
            for dep in root[2]:
                try:
                    text.text_formatting(dep.text + " ==> " + get_description(dep.text), 1, 'info')
                except:
                    text.text_formatting(dep.text + _(" ==> There is no description for this suprapackage"), 1, 'warning')
            if cons.confm:
                answer = _("Y")
            else:
                answer = input(_("Are you want to remove these suprapackages (Y/N): "))
                answer = answer.upper()
            if answer == _("Y"):
                for dep in root[2]:
                    package = dep.text
                    functions.remove(package,"skip",source)
            else:
                text.text_formatting(_("Dependencies coulnd't removed so remove process couldn't continue."), 0, 'error')
                sys.exit(1)
        else:
            text.text_formatting(_("Following suprapackage(s) will install. "), 0, 'info')
            for dep in root[2]:
                if not search.srch_pynr(dep.text,'Peynir/Name','absolute') and not suprapackage_check(str(dep.text)):
                    text.text_formatting(dep.text + _(" couldn't found in repository, you can install it manually"), 1, 'warning')
                    os.remove(cons.sprpckg_dir + source + ".xml")
                    sys.exit(1)
                else:
                    try:
                        text.text_formatting(dep.text + " ==> " + get_description(dep.text), 1, 'info')
                    except:
                        text.text_formatting(dep.text + _(" ==> There is no description for this suprapackage"), 1, 'info')
            if cons.confm:
                answer = _("Y")
            else:
                answer = input(_("Are you want to install these suprapackages (Y/N): "))
                answer = answer.upper()
            if answer == _("Y"):
                for dep in root[2]:
                    package = dep.text
                    if not functions.suprapackage_check(package):
                        functions.install(package,"","") #İç içe bağımlılık sorunu olacak o neden ilave bir fonksiyon paramatresi ise bu soruyu bir kez sordurulabilir
                    else:
                        text.text_formatting(">> " + package + _(" is already installed"), 0, 'info')
                    mdfy.modify_add(cons.sprpckg_dir+package+".xml","<Dependencies","'>"," " + source,"previous") 
            else:
                os.remove(cons.sprpckg_dir+source+".xml")
                text.text_formatting(_("Dependencies coulnd't installed so install process couldn't continue."), 0, 'error')
                sys.exit(1)
    else:
        text.text_formatting(_("There is a no dependencies"), 1, 'info')
示例#36
0
文件: peynir.py 项目: lonicera/Peynir
def main():
    if not os.geteuid()==0:
        sys.exit(_("You must be root to run this application, please use sudo and try again."))
    functions.db_file_check()
    parser = argparse.ArgumentParser(description='''Suprapackage Manager for Archlinux. It's also a framework for configuring Archlinux or other pacman based distribution.''', prog='peynir')
    parser.add_argument("-d", "--debug", help="Log everyhing (including info, warning and errors)", action="store_true")
    parser.add_argument("-S", nargs='*', metavar='Suprapackage', help="Install suprapackage")
    parser.add_argument("-U", metavar='Suprapackage', help="Install local suprapackage")
    parser.add_argument("-R", nargs='*', metavar='Suprapackage', help="Remove suprapackage")
    parser.add_argument("-Rs", nargs='*', metavar='Suprapackage', help="Remove suprapackage and its dependencies")
    parser.add_argument("-Sy", help="Update repository", action="store_true")
    parser.add_argument("-Syy", help="Update peynir and pacman repository", action="store_true")   
    parser.add_argument("-Su", help="Upgrade the system", action="store_true")
    parser.add_argument("-Syu", help="Upgrade the system", action="store_true")  
    parser.add_argument("-Ss", help="Search suprapackege in repository")  
    parser.add_argument("-Qs", help="Search suprapackege in local")
    parser.add_argument("-O", help="Repair system or package (not fully implemented)")
    parser.add_argument("--noconfirm", help="Do not prompt for any confirmation", action="store_true")
    parser.add_argument("--cachedir", help="[path] Overrides the default location of the suprapackage cache directory.")
    parser.add_argument("--silence", help="No output", action="store_true")

    args = parser.parse_args()
    
    if len(sys.argv)==1:
        parser.print_help()
        sys.exit(1)
    if args.noconfirm:
        cons.confm = True
    if args.debug:
        cons.debug = True
    if args.silence:
        cons.silence = True
    if args.cachedir:
        cons.cachedir = args.cachedir.strip()
        if not cons.cachedir[len(cons.cachedir)-1:len(cons.cachedir)] == "/":
            cons.cachedir = cons.cachedir+"/"
            print(cons.cachedir)
    
    if args.Sy:
        functions.sync_repo(0)
    if args.Syy:
        functions.sync_repo(1)
    if args.Su:
        functions.upgrade()
    if args.Syu:
        functions.sync_repo(1)
        functions.upgrade()
    if args.S:
        functions.db_file_check() #Burada ve diğer gereksiz kullanımları temizle
        for i in args.S:
            rqst = i.lower()
            if search.srch_pynr(rqst,'Peynir/Name','absolute'):
                functions.install(rqst,"","")
            else:
                text.text_formatting('error: '+ rqst +' no such a suprapackage',0, "warning")
    
    if args.R:
       functions.db_file_check() 
       for i in args.R:
           rqst = i.lower()
           functions.remove(rqst,"","")
    if args.Rs:
       functions.db_file_check() 
       for i in args.Rs:
           rqst = i.lower()
           functions.remove(rqst,"complete","")
    if args.Ss:
       functions.db_file_check() 
       for i in args.Ss.split():
           rqst = i.lower()
           text.text_formatting("Results for " + rqst, 0, 'info')
           search.srch_pynr(rqst,'Peynir/Name','find')
    if args.Qs:
       functions.db_file_check() 
       for i in args.Qs.split():
           rqst = i.lower()
           text.text_formatting("Results for " + rqst, 0, 'info' )
           search.local_search(rqst)
    if args.U:
       functions.db_file_check() 
       if "/" in args.U:
           position = args.U.rfind('/')
           adress = args.U[:position]
           package = args.U[position+1:]
       else:
           adress = ""
       if package[-3:] != "xml" and "." in package:
           text.text_formatting(_("Invalid package format"), 0, "error")
           sys.exit(1)
       elif not "." in package: 
           package = package+".xml"
             
       if not functions.suprapackage_check(package[:-4]):
           functions.install(package,"local",adress)
       else:
           text.text_formatting(_(">> This suprapackage already installed in your system."), 0, 'error')