コード例 #1
0
ファイル: main.py プロジェクト: krauson/Tic-Tac-Toe
def main():
    args = sys.argv[1:]

    if len(args) < 1:
        logging.warning('Usage: python <filename> <function> <parameters..>')

    elif args[0] == 'init':
        init()

    elif args[0] == 'add':

        data_to_copy_path = args[1]
        add(data_to_copy_path)

    elif args[0] == 'commit':
        message = args[1]
        commit(message)

    elif args[0] == 'status':
        status()

    elif args[0] == 'checkout':
        commit_id = args[1]
        checkout(commit_id)

    elif args[0] == 'graph':
        graph()

    elif args[0] == 'branch':
        branch_name = args[1]
        branch(branch_name)

    elif args[0] == 'merge':
        branch_name = args[1]
        merge()
コード例 #2
0
def merge(branch: str, wit_path: str):
    """Merges two commits in to a new commit."""

    if _can_checkout:
        if is_branch(wit_path, branch):
            branch_on_head = _get_references_data(wit_path)["HEAD"]
            branch_id = _get_references_data(wit_path)[branch]
            if _get_head(wit_path) == branch_on_head:
                commit_id = commit(
                    f'A merge between "{branch_on_head}" and "{branch}"',
                    wit_path, branch_id)

            else:
                common_parent = _get_common_parent(wit_path,
                                                   _get_head(wit_path),
                                                   branch_id)
                _move_files(wit_path, common_parent, branch_id)
                commit_id = commit(
                    f'A merge between "{branch_on_head}" and "{branch}"',
                    wit_path, branch_id)
                checkout(branch_on_head, wit_path)

            logging.info(
                f'"{branch}" was successfully merged with {branch_on_head}.')
            print(commit_id)

        else:
            logging.error(
                f'"{branch}" is not a branch, try "branch" function to create a new branch.'
            )
コード例 #3
0
def merge(branch_name):
    current_folder = Path.cwd()
    wit_folder = find.find_wit_folder(current_folder)

    if not wit_folder:
        return False

    branch_id, index = activated.get_active_id(wit_folder, branch_name)
    branch_id_list = graph.id_list(branch_id, wit_folder)

    head_id = activated.get_ref_file(wit_folder)[0].split('=')[1].strip()
    head_id_list = graph.id_list(head_id, wit_folder)

    common_id = find_common_id(branch_id_list, head_id_list)

    base_files_path = Path(wit_folder, '.wit', 'images', common_id)
    # base_files = [f for f in base_files_path.rglob('*') if f.is_file()]
    branch_files_path = Path(wit_folder, '.wit', 'images', branch_id)
    branch_files = [f for f in branch_files_path.rglob('*') if f.is_file()]

    new_files = []
    status.compare_files(branch_files, "", branch_files_path, base_files_path,
                         new_files, new_files)

    for file in new_files:
        src = file.relative_to(branch_files_path)
        dst = Path(wit_folder, '.wit', 'staging_area', src)
        copy2(src, dst)

    commit.commit('merge', merge=True)
コード例 #4
0
ファイル: main.py プロジェクト: gosquadron/squadron
def _deploy(squadron_dir, new_dir, last_dir, commit_info,
        this_run_sum, last_run_sum, last_commit, dont_rollback,
        resources, force):
    log.info("Applying changes")
    log.debug("Changes: %s", commit_info)
    commit.commit(commit_info)

    paths_changed, new_paths = _get_hash_diff(last_run_sum, this_run_sum, force)

    log.debug("Paths changed: %s", paths_changed)
    log.debug("New paths: %s", new_paths)

    _run_actions(squadron_dir, new_dir, commit_info, resources, paths_changed,
            new_paths)

    # Now test
    try:
        _run_tests(squadron_dir, commit_info)
    except TestException:
        # Roll back
        if last_commit and not dont_rollback:
            log.error("Rolling back to %s because tests failed", last_commit)
            # Flip around the paths changed and new_paths
            _deploy(squadron_dir, last_dir, None, last_commit, last_run_sum,
                    {}, None, dont_rollback, resources, False)
        raise
コード例 #5
0
ファイル: repo343.py プロジェクト: csulb-cmw/repo343
def call_merge(project_root, repo_directory):
    import merge
    import checkout    
    foreign_repo = merge.ask_user_repo_name(project_root, repo_directory)
    merge_id = merge.ask_user_for_commit_id(foreign_repo, repo_directory)
    #TODO I think we have to make a commit here
    checkout.checkout(project_root, repo_directory, merge_id, foreign_repo )
    commit.commit("merge commit", project_root, repo_directory)
コード例 #6
0
ファイル: repo343.py プロジェクト: csulb-cmw/repo343
def call_commit(project_root, repo_directory):
    """process args for a commit message, and call it
    """
    import commit
    import pathing
    # process the args
    # did the user specify a commit message?
    commit_message = get_argv_option( '-m' )
    if not commit_message:
        commit_message = ""
    commit.commit(commit_message, project_root, repo_directory)
コード例 #7
0
def init(project_root, repo_directory):
    """perform a repo initialization
    """

    # create manifests folder
    partial_path_to_manifest = pathing.get_manifest_directory(repo_directory)

    if not os.path.exists(partial_path_to_manifest):
        os.makedirs(partial_path_to_manifest)

    #do the first commit
    commit.commit("initial", project_root, repo_directory)
コード例 #8
0
def photoeditor(request, lang):
    import os, sys, inspect
    from . import translations
    import json

    langs = ["cs", "en"]
    if lang in langs:
        langs.remove(lang)
        currentdir = os.path.dirname(
            os.path.abspath(inspect.getfile(inspect.currentframe())))
        parentdir = os.path.dirname(currentdir)
        sys.path.insert(0, parentdir)

        import commit
        commit = commit.commit("main")
        commitZkraceny = commit[:7]
        # přidání překladů do contextů
        preklad = json.loads(translations.translation(lang))
        context = {
            "commit": commit,
            "commitZkraceny": commitZkraceny,
            "verze": "1.3.3",
            "datum_vydani": "12.4.2021",
            "lang": lang,
            "langs": langs
        }
        context.update(preklad)
        return render(request, 'editor.html', context)
    else:
        return render(request, 'documention.html')
        return redirect(photoeditor, lang="cs")
コード例 #9
0
    def dumpLog(self, sha, committer, commit_date, author, author_date,
                change_files):

        if sha is None:
            return False

        if self.sha2commit.has_key(sha):
            print "!!! sould not have this key"

        project = self.project.split(os.sep)[-1]
        co = commit(project, sha)
        co.committer = committer
        co.commit_date = commit_date
        co.author = author
        co.author_date = author_date

        for ch in change_files:
            insertion, deletion, file_name = ch[0], ch[1], ch[2]
            lang_extension = os.path.splitext(file_name)[1].strip().lower()
            tag = util.extn2tag.get(lang_extension, None)

            if not tag is None:
                co.addChange(insertion, deletion, file_name, tag)

        self.sha2commit[sha] = co
コード例 #10
0
def vote(PP, v_id, vote_arr, public_seed, BB):
    seed = randombytes(PP.seedlen)
    r_seed = randombytes(PP.seedlen)
    nonce = 0

    B0, b = gen_public_b(PP, public_seed)
    m = m_from_vote_arr(PP, vote_arr)
    x, _ = _secret_share_value(PP, m, PP.Na, seed, 0)

    S = []
    T0 = []
    T1 = []
    for i in range(PP.Na):
        t0, t1, r, nonce = commit(PP, B0, b, x[i], r_seed, nonce)
        S.append(r)
        T0.append(t0)
        T1.append(t1)

    r = list(sum(S[j][i] for j in range(PP.Na)) for i in range(PP.baselen))
    t0, t1 = commit_with_r(PP, B0, b, m, r)
    vproof, additional_com = proof_v(PP, t0, t1, r, m, public_seed)

    # We should sign ballots
    signature = None

    # S should be encrypted
    ballot = Ballot(v_id, vproof, (T0, T1), additional_com, S, signature)
    BB.add_ballot(ballot)
コード例 #11
0
ファイル: init.py プロジェクト: WilliamPerezIII/repo343
def init(argv):
    """perform a repo initialization

    :argv: the argument vars passed from the console.
    
    TODO argv should be preprocessed.
    
    """

    cwd = os.getcwd()

    # create manifests folder
    if os.path.exists(cwd + "/repo343/manifests"):
        print( "Error: manifests directory exists." )
        exit()
    os.makedirs(cwd + "/repo343/manifests" )

    #do the first commit
    commit.commit( "initial", cwd + "/repo343/manifests", "none" )
コード例 #12
0
def _gen_random_commitments_impl(PP, p, public_seed, m_func):
    R = PP.R

    B0, b = gen_public_b(PP, public_seed)

    r_seed = randombytes(PP.seedlen)
    seed = randombytes(PP.seedlen)
    S = []
    T0 = []
    T1 = []
    nonce = 0
    for i in range(p):
        xi = []
        for i in range(PP.npoly):
            x, nonce = m_func(PP, seed, nonce, PP.d)
            xi.append(x)
        t0, t1, r, nonce = commit(PP, B0, b, xi, r_seed, nonce)
        S.append(r)
        T0.append(t0)
        T1.append(t1)
    return Matrix(R, S).transpose(), Matrix(R, T0).transpose(), Matrix(
        R, T1).transpose()
コード例 #13
0
ファイル: xmlReadSoup.py プロジェクト: saheel1115/szz
def parse_xml(xml_file):

  print("===> processing %s" % str(xml_file))

  commit_list = []

  co = None

  handler = open(xml_file).read()
  soup = Soup(handler, 'lxml')

  for entry in soup.findAll('commit'):
      #print entry
      #print "------------------"
      sha = entry.sha.string
      project = entry.project.string

      co = commit(project, sha)
      co.committer   = entry.committer.string if not  entry.committer is None else ""
      co.commit_date = entry.commit_date.string if not  entry.commit_date is None else ""
      co.author      = entry.author.string if not  entry.author is None else ""
      co.author_date = entry.author_date.string if not  entry.author_date is None else ""
      co.isbug       = entry.bug.string if not entry.bug is None else ""
      co.subject     = entry.subject.string if not entry.subject is None else ""
      co.body        = entry.body.string if not entry.body is None else ""

      changes        = entry.findAll('change')

      for ch in changes:
          add       = ch.add.string if not ch.add is None else ""
          delete    = ch.delete.string if not ch.delete is None else ""
          file_name = ch.file.string if not ch.file is None else ""
          language  = ch.language.string if not ch.language is None else ""
          co.addChange(add, delete, file_name,language)

      commit_list.append(co)

  return commit_list
コード例 #14
0
ファイル: wit.py プロジェクト: IdanPelled/Wit-VCS
def commands() -> None:
    """Redirects all the commands that require a wit path."""

    wit_path = _search_parent_dir(".wit")
    _set_logger(os.path.join(wit_path, '.wit'))

    if sys.argv[1] == 'add':
        add(sys.argv[2], wit_path)
    elif sys.argv[1] == 'commit':
        print(commit(sys.argv[2], wit_path))
    elif sys.argv[1] == 'status':
        print(status(wit_path))
    elif sys.argv[1] == 'checkout':
        checkout(sys.argv[2], wit_path)
    elif sys.argv[1] == 'graph':
        graph(wit_path)
    elif sys.argv[1] == 'branch':
        branch(sys.argv[2], wit_path)
    elif sys.argv[1] == 'merge':
        merge(sys.argv[2], wit_path)
    else:
        logging.error(
            MethodNotFoundError(f'unrecognized method: "{sys.argv[1]}".'))
コード例 #15
0
ファイル: ghProcNoPatch.py プロジェクト: dSar-UVA/repoMiner
    def dumpLog(self, sha, committer, commit_date, author, author_date, change_files):

        if sha is None:
            return False

        if self.sha2commit.has_key(sha):
            print "!!! sould not have this key"

        project = self.project.split(os.sep)[-1]
        co  = commit(project, sha)
        co.committer = committer
        co.commit_date = commit_date
        co.author = author
        co.author_date = author_date

        for ch in change_files:
            insertion, deletion, file_name = ch[0], ch[1], ch[2]
            lang_extension = os.path.splitext(file_name)[1].strip().lower()
            tag = extn2tag.get(lang_extension, None)

            if not tag is None:
                co.addChange(insertion, deletion, file_name, tag)
                
        self.sha2commit[sha] = co
コード例 #16
0
ファイル: snapinstaller.py プロジェクト: DBCDK/opensearch
def snap_install( solr_root , slave_dir, solr_hostname, solr_port, solr_webapp, master_status_dir, slave_status_dir ):
    """
    Function used to install a
    snapshot into place, and commit
    changes to solr instance
    """
    
    ## generate status folders if none are specified
    if master_status_dir == "":
        master_status_dir = os.path.join(solr_root, "logs", "master_status")
    if slave_status_dir == "":
        slave_status_dir = os.path.join(solr_root, "logs", "slave_status")

    master_status_file = os.path.join(master_status_dir,"snappuller.status")+".%s"%socket.gethostname()
    slave_status_file = os.path.join(slave_status_dir,"snappuller.status")
    slave_snapshot_current_file = os.path.join(solr_root, "logs","snapshot.current")
    master_snapshot_current_file = os.path.join(master_status_dir, "snapshot.current")
    
    lockdir = os.path.join(solr_root, "logs", "snapinstaller-lock")
    pidfile = os.path.join(lockdir, "PID")
    
    # check old pidfile
    if os.path.exists(pidfile):
        other_pid = open(pidfile).read().strip()
        cmd_str = "kill -0 %s &>/dev/null"%(other_pid)
        retcode = subprocess.Popen( cmd_str, shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE ).communicate()
        if retcode[1]:
            print "process %s not active, removing stale PIDFILE: %s"%(other_pid ,pidfile)
            os.remove(pidfile)
        else:
            print "Lock failed PID '%s' is active"%other_pid
            exit(3)

    # write new pidfile
    if not os.path.exists(lockdir):
        os.mkdir(lockdir)
    pf = open(pidfile, 'w')
    pf.write(str(os.getpid()));
    pf.close();

    # get snapshot filename
    cmd_str = "find %s -name snapshot.\* | sort -r  | head -1"%slave_dir
    retcode = subprocess.Popen( cmd_str, shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE ).communicate()
    if retcode[1]:
        print "Caught error during snapshot check: '%s'" % retcode[1]
        exit(3)
    if retcode[0].strip() == "":
        print "no snapshots available"
        exit(4)

    # has snapshot already been installed
    last_snapname = retcode[0].strip()
    if os.path.exists(slave_snapshot_current_file):
        current = open(slave_snapshot_current_file).read().strip()
        print "DEBUG last_snapname '%s', current '%s'"%(last_snapname, current)
        if os.path.split(last_snapname)[1] in current:
            print "latest snapshot %s already installed"%last_snapname
            exit(5);

    # install using hard links into temporary directory
    # remove original index and then atomically copy new one into place
    cmd_str = "cp -lr %s/ %s/index.tmp%s  && rm -rf %s/index && mv -f %s/index.tmp%s %s/index "% \
              (last_snapname, slave_dir, os.getpid(), slave_dir, slave_dir, os.getpid(), slave_dir )
    retcode = subprocess.Popen( cmd_str, shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE ).communicate()
    if retcode[1]:
        print "Caught error during snapshot copy: '%s'" % retcode[1]
        exit(3)

    # update stats
    push_status([slave_snapshot_current_file, master_snapshot_current_file], last_snapname)
    
    # notify Solr to open a new Searcher
    commit.commit(solr_hostname, solr_port, solr_webapp)    

    shutil.rmtree(lockdir)
コード例 #17
0
ファイル: main.py プロジェクト: 31core/PyVCS
import os
import sys
import staging
import commit
import log
import reset
import restore


def init():
    os.mkdir(".vcs")
    os.mkdir(".vcs/staging")


staging = staging.staging()
if __name__ == "__main__":
    if sys.argv[1] == "init":
        init()
    elif sys.argv[1] == "add":
        staging.add(sys.argv[2])
    elif sys.argv[1] == "restore":
        restore.restore(sys.argv[2])
    elif sys.argv[1] == "commit":
        commit.commit()
    elif sys.argv[1] == "log":
        for i in log.get_log_line():
            print(i)
    elif sys.argv[1] == "reset":
        reset.reset()
コード例 #18
0
item += 'COMMIT'.ljust(15)
print(item)

# Main Code
while (len(ROB) > 0) | (cycle == 1):

    # ISSUE stage
    if (PC.PC < len(instructions)) & (PC.valid == 1):
        issue(cycle, PC, instructions, ROB, size_ROB, rs_int_adder,
              rs_fp_adder, rs_fp_multi, ld_sd_queue, size_ld_sd_queue, rat_int,
              rat_fp)

    # EXE stage
    exe(fu_int_adder, time_fu_int_adder, fu_fp_adder, time_fu_fp_adder,
        fu_fp_multi, time_fu_fp_multi, results_buffer, rs_int_adder,
        rs_fp_adder, rs_fp_multi, ld_sd_exe, time_ld_sd_exe, ld_sd_queue,
        cycle, ROB, PC)

    # MEM stage
    mem(ld_sd_queue, ld_sd_mem, time_ld_sd_mem, results_buffer, memory, ROB,
        cycle)

    # CDB stage
    wb(cdb, rat_int, rat_fp, rs_int_adder, rs_fp_adder, rs_fp_multi,
       ld_sd_queue, ROB, cycle, results_buffer)

    # COMMIT stage
    commit(ROB, reg_int, reg_fp, cycle, instructions)

    # cycle number
    cycle += 1
コード例 #19
0
def parse_xml(xml_doc, lang='java'):
    print "---> parse_xml_all"
    context = ET.iterparse(xml_doc, events=("start", "end"))

    file_name = os.path.basename(xml_doc)
    file_name = os.path.splitext(file_name)[0]
    project = ""

    commit_list = []

    co = None

    add = None
    delete = None
    file_name = None

    count = 0
    for event, element in context:
        if event is "start":
            if element.tag == 'commit':
                if not co is None:
                    commit_list.append(co)
                co = None
                add = None
                delete = None
                file_name = None
                count += 1

            if element.tag == "sha":
                co = commit(project, element.text)
                #co.sha = element.text
            elif element.tag == "tag":
                co.tag = element.text
            elif element.tag == "project":
                co.project = element.text
            elif element.tag == "committer":
                co.committer = element.text
            elif element.tag == "commit_date":
                co.commit_date = element.text
            elif element.tag == "author":
                co.author = element.text
            elif element.tag == "author_date":
                co.author_date = element.text
            elif element.tag == "bug":
                co.isbug = element.text
            elif element.tag == "bug_type_root":
                co.bug_type_root = element.text
            elif element.tag == "bug_type_impact":
                co.bug_type_impact = element.text
            elif element.tag == "bug_type_component":
                co.bug_type_comp = element.text
            elif element.tag == "subject":
                co.subject = element.text
            elif element.tag == "body":
                co.body = element.text
            elif element.tag == "add":
                add = element.text
            elif element.tag == "delete":
                delete = element.text
            elif element.tag == "file":
                file_name = element.text
            elif element.tag == "language":
                language = element.text

        if event is "end" and element.tag == "change":
            co.addChange(add, delete, file_name, language)

    commit_list.append(co)

    return commit_list
コード例 #20
0
ファイル: main.py プロジェクト: krauson/Tic-Tac-Toe
        status()

    elif args[0] == 'checkout':
        commit_id = args[1]
        checkout(commit_id)

    elif args[0] == 'graph':
        graph()

    elif args[0] == 'branch':
        branch_name = args[1]
        branch(branch_name)

    elif args[0] == 'merge':
        branch_name = args[1]
        merge()


# if __name__ == '__main__':

#     main()

os.chdir(r"C:\Users\Hagai\Desktop\week1\week1")
# init()
# add(r'C:\Users\Hagai\Desktop\week1\week1\hagai\hello.py.txt')
commit('hey')
# status()
# checkout('koko')
# graph()
# branch('koko')
コード例 #21
0

if __name__ == '__main__':
    from commit import commit
    from params import PublicParams
    from public import gen_public_b
    from utils import m_from_vote_arr
    public_seed = b'-\xc2\xbd\xc1\x12\x94\xac\xd0f\xab~\x9f\x13\xb5\xac\xcaT\xbaFgD\xa6\x93\xd9\x92\xf2"\xb5\x006\x02\xa3'

    PP = PublicParams(2, 129, 10)
    v = [0] * PP.Nc
    v[1] = 1
    m = m_from_vote_arr(PP, v)
    B0, b1 = gen_public_b(PP, public_seed)
    r_seed = randombytes(PP.seedlen)
    t0, t1, r, _ = commit(PP, B0, b1, m, r_seed, 0)

    proof, additional_com = proof_v(PP, t0, t1, r, m, public_seed)
    ver_result = verify_v(PP, proof, (t0, t1), additional_com, public_seed)
    if ver_result == 0:
        print('Verify is successfull')
    else:
        print('There is an error in verification')

    print('Trying negative scenarios')
    for v in ([1]*2 + [0]*(PP.Nc - 2), [2] + [0]*(PP.Nc - 1)):
        m = m_from_vote_arr(PP, v)
        B0, b1 = gen_public_b(PP, public_seed)
        r_seed = randombytes(PP.seedlen)
        t0, t1, r, _ = commit(PP, B0, b1, m, r_seed, 0)
コード例 #22
0
def sum_of_commitments(PP, S, T0, T1, public_seed):
    d = PP.d
    X = PP.X
    u = PP.u
    npoly = PP.npoly

    p = len(S)
    max_layers = ceil(log(p, u))

    B0, b = gen_public_b(PP, public_seed)
    X_poly = list(
        list(T1[i][j] - scalar(b[j], S[i], X, d) for j in range(npoly))
        for i in range(p))

    S_amo = []
    T0_amo = []
    T1_amo = []
    S_amo_zero = []
    T0_amo_zero = []
    T1_amo_zero = []
    for i in range(p):
        S_amo.append(S[i])
        T0_amo.append(T0[i])
        T1_amo.append(T1[i])
    r_seed = randombytes(PP.seedlen)
    nonce = 0
    max_index = p
    offset = 0
    for layer in range(1, max_layers + 1):
        blocks = ceil(p / u**layer)
        for block in range(blocks):
            start = block * u
            end = min((block + 1) * u, max_index)
            m = list(
                sum(X_poly[i][j] for i in range(start, end))
                for j in range(npoly))
            X_poly[block] = m
            t0, t1, r, nonce = commit(PP, B0, b, m, r_seed, nonce)

            t0_prime = list(t0[i] - sum(T0_amo[j + offset][i]
                                        for j in range(start, end))
                            for i in range(PP.kappa))
            t1_prime = list(t1[i] - sum(T1_amo[j + offset][i]
                                        for j in range(start, end))
                            for i in range(npoly))
            r_prime = list(r[i] - sum(S_amo[j + offset][i]
                                      for j in range(start, end))
                           for i in range(PP.baselen))

            T0_amo.append(t0)
            T1_amo.append(t1)
            S_amo.append(r)
            T0_amo_zero.append(t0_prime)
            T1_amo_zero.append(t1_prime)
            S_amo_zero.append(r_prime)
        offset += max_index
        max_index = blocks

    R = PP.R
    amo_proof = proof_amo(PP,
                          Matrix(R, S_amo).transpose(),
                          Matrix(R, T0_amo).transpose(), len(T1_amo),
                          public_seed)
    amo_zero_proof = proof_amo_to_zero(PP,
                                       Matrix(R, S_amo_zero).transpose(),
                                       Matrix(R, T0_amo_zero).transpose(),
                                       Matrix(R, T1_amo_zero).transpose(),
                                       len(T1_amo_zero), public_seed)
    return amo_proof, amo_zero_proof, (T0_amo[p:], T1_amo[p:]), S_amo[-1]