From 47530462bcbd954f7047cd6e80ab2cf0b89295a7 Mon Sep 17 00:00:00 2001 From: Curtis Lacy Date: Thu, 23 Jan 2014 09:05:22 -0500 Subject: [PATCH 1/3] Add a command line argument which lets us specify the location of the mastercoin-tools repository. --- msc_archive.py | 4 +++- msc_parse.py | 4 +++- msc_utils_general.py | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/msc_archive.py b/msc_archive.py index 4896967..becc6f9 100644 --- a/msc_archive.py +++ b/msc_archive.py @@ -9,12 +9,14 @@ def main(): parser = OptionParser("usage: %prog [options]") parser.add_option("-d", "--debug", action="store_true",dest='debug_mode', default=False, help="turn debug mode on") + parser.add_option( "-r", "--repository-path", dest='repository_path', default="~/mastercoin-tools", + help="Specify the location of the mastercoin-tools repository (defaults to ~/mastercoin-tools" ) (options, args) = parser.parse_args() d=options.debug_mode # zip all parsed data and put in downloads - archive_parsed_data() + archive_parsed_data( options.repository_path ) if __name__ == "__main__": main() diff --git a/msc_parse.py b/msc_parse.py index 3336f03..8bb75b6 100644 --- a/msc_parse.py +++ b/msc_parse.py @@ -23,6 +23,8 @@ def parse(): help="start the parsing at a specific block height (default is last)") parser.add_option("-a", "--archive-parsed-data", action="store_true",dest='archive', default=False, help="archive the parsed data of tx addr and general for others to download") + parser.add_option( "-r", "--repository-path", dest='repository_path', default="~/mastercoin-tools", + help="Specify the location of the mastercoin-tools repository (defaults to ~/mastercoin-tools" ) (options, args) = parser.parse_args() d=options.debug_mode @@ -250,7 +252,7 @@ def parse(): atomic_json_dump(rev, 'www/revision.json', add_brackets=False) if archive: - archive_parsed_data() + archive_parsed_data( options.repository_path ) if __name__ == "__main__": parse() diff --git a/msc_utils_general.py b/msc_utils_general.py index c8c6643..7ea14fb 100644 --- a/msc_utils_general.py +++ b/msc_utils_general.py @@ -101,14 +101,14 @@ def get_git_details(directory="~/mastercoin-tools"): return(head_commit.hexsha,timestamp) def archive_repo(directory="~/mastercoin-tools"): - (commit_hexsha, timestamp)=get_git_details() + (commit_hexsha, timestamp)=get_git_details( directory ) assert repo.bare == False archive_name='www/downloads/mastercoin-tools-src-'+timestamp+'-'+commit_hexsha[:8]+'-'+timestamp+'.tar' repo = git.Repo(directory) repo.archive(open(archive_name,'w')) def archive_parsed_data(directory="~/mastercoin-tools"): - (commit_hexsha, timestamp)=get_git_details() + (commit_hexsha, timestamp)=get_git_details( directory ) archive_name='www/downloads/mastercoin-tools-parse-snapshot-'+timestamp+'-'+commit_hexsha[:8]+'.tar.gz' path_to_archive='www/revision.json www/tx www/addr www/general/' out, err = run_command("tar cz "+path_to_archive+" -f "+archive_name) From 2d87bf451b42d710644bf4099737627abc89e584 Mon Sep 17 00:00:00 2001 From: Curtis Lacy Date: Thu, 23 Jan 2014 09:34:43 -0500 Subject: [PATCH 2/3] Added the optional tools path to calls to get_revision_dict. --- msc_parse.py | 2 +- msc_utils_general.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/msc_parse.py b/msc_parse.py index 8bb75b6..44011a1 100644 --- a/msc_parse.py +++ b/msc_parse.py @@ -248,7 +248,7 @@ def parse(): if single_tx == None and block != None: msc_globals.last_block=block - rev=get_revision_dict(last_block) + rev=get_revision_dict( last_block, options.repository_path ) atomic_json_dump(rev, 'www/revision.json', add_brackets=False) if archive: diff --git a/msc_utils_general.py b/msc_utils_general.py index 7ea14fb..aac2664 100644 --- a/msc_utils_general.py +++ b/msc_utils_general.py @@ -123,9 +123,9 @@ def get_now(): def get_today(): return format_time_from_struct(time.gmtime(), True) -def get_revision_dict(last_block): +def get_revision_dict( last_block, directory="~/mastercoin-tools" ): rev={} - git_details=get_git_details() + git_details=get_git_details( directory ) hexsha=git_details[0] commit_time=git_details[1] rev['commit_hexsha']=hexsha From 24548ae2a67a279cc3d3d6c1305b8c9457013acc Mon Sep 17 00:00:00 2001 From: Patrick Madden Date: Tue, 28 Jan 2014 17:46:56 -0600 Subject: [PATCH 3/3] Changes the output of msc_validate to rename the sell offer files --- msc_cron.sh | 2 +- msc_validate.py | 28 ++++++++++++++-------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/msc_cron.sh b/msc_cron.sh index 0eddd70..23c28b0 100644 --- a/msc_cron.sh +++ b/msc_cron.sh @@ -29,7 +29,7 @@ python msc_validate.py 2>&1 > $VALIDATE_LOG cp tx/* www/tx/ cp addr/* www/addr/ cp general/* www/general/ -cp bids/* www/bids/ +cp offers/* www/offers/ mkdir -p www/mastercoin_verify/addresses/ cp mastercoin_verify/addresses/* www/mastercoin_verify/addresses/ mkdir -p www/mastercoin_verify/transactions/ diff --git a/msc_validate.py b/msc_validate.py index 0f70c4a..aef77ec 100644 --- a/msc_validate.py +++ b/msc_validate.py @@ -44,7 +44,7 @@ coins_reverse_short_name_dict=dict((v,k) for k, v in coins_short_name_dict.iteritems()) # create modified tx dict which would be used to modify tx files -bids_dict={} +offers_dict={} # global last block on the net last_height=get_last_height() @@ -330,11 +330,11 @@ def mark_tx_invalid(tx_hash, reason): update_tx_dict(tx_hash, invalid=(True,reason), color='bgc-invalid') # add another sell tx to the modified dict -def add_bids(key, t): - if bids_dict.has_key(key): - bids_dict[key].append(t) +def add_offers(key, t): + if offers_dict.has_key(key): + offers_dict[key].append(t) else: - bids_dict[key]=[t] + offers_dict[key]=[t] # write back to fs all tx which got modified @@ -347,11 +347,11 @@ def write_back_modified_tx(): # save back to filesystem atomic_json_dump(tx_dict[k], 'tx/'+k+'.json', add_brackets=False) -# create bids json -def update_bids(): - for tx_hash in bids_dict.keys(): - # write updated bids - atomic_json_dump(bids_dict[tx_hash], 'bids/bids-'+tx_hash+'.json', add_brackets=False) +# create offers json +def update_offers(): + for tx_hash in offers_dict.keys(): + # write updated offers + atomic_json_dump(offers_dict[tx_hash], 'offers/offers-'+tx_hash+'.json', add_brackets=False) def update_bitcoin_balances(): chunk=100 @@ -698,9 +698,9 @@ def check_mastercoin_transaction(t, index=-1): update_tx_dict(sell_offer_tx['tx_hash'], color='bgc-accepted', icon_text='Sell offer accepted') else: mark_tx_invalid(t['tx_hash'],'non positive spot accept') - # add to current bids (which appear on seller tx) + # add to current offers (which appear on seller tx) key=sell_offer_tx['tx_hash'] - add_bids(key, t) + add_offers(key, t) return True else: info('unknown tx type: '+t['tx_type_str']+' in '+tx_hash) @@ -778,8 +778,8 @@ def validate(): except OSError: error('error on tx '+t['tx_hash']) - # create json for bids - update_bids() + # create json for offers + update_offers() # update changed tx write_back_modified_tx()