本文整理汇总了Python中FileSync.get_file_list方法的典型用法代码示例。如果您正苦于以下问题:Python FileSync.get_file_list方法的具体用法?Python FileSync.get_file_list怎么用?Python FileSync.get_file_list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileSync
的用法示例。
在下文中一共展示了FileSync.get_file_list方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1:
# 需要导入模块: import FileSync [as 别名]
# 或者: from FileSync import get_file_list [as 别名]
msg_header_lines = msg_header.splitlines()
request_type, request_path = msg_header_lines[0].split(' ',1)
print "Request Type: %s" % request_type
print "Request Path: %s" % request_path
if request_type == "PUT":
fullpath = './static/data/' + request_path
response_code = FileSync.put_file(fullpath, 'text/plain', msg_body)
client_sock.send('HTTP/1.1 ' + response_code + '\n')
files_received += 1
elif request_type == "GET":
fullpath = './static/data/' + request_path
if os.path.isdir(fullpath):
file_list = FileSync.get_file_list(fullpath)
response_body = ''
for file_name in file_list:
response_body += file_name + '\n'
client_sock.send('HTTP/1.1 ' + '200 OK' + '\n\n')
client_sock.send(response_body + '\n')
else:
response_body = FileSync.get_file(fullpath)
if response_body != '':
client_sock.send('HTTP/1.1 ' + '200 OK' + '\n\n')
client_sock.send(response_body + '\n\n')
else:
client_sock.send('HTTP/1.1 ' + '404 Not Found' + '\n\n')
print "Request Complete\n"
示例2: process_json_files
# 需要导入模块: import FileSync [as 别名]
# 或者: from FileSync import get_file_list [as 别名]
def process_json_files(global_config, competition, output_file, input_dir, reprocess_files=False):
# Initialize the database session connection
db_name = global_config['db_name'] + global_config['this_season']
session = DbSession.open_db_session(db_name)
# get all the verified files from the input directory. These files are
# candidates to be processed
verified_files = FileSync.get_file_list(input_dir, ext='.verified', recurse=True )
verified_files.sort(key=match_sort)
# For the normal case, get all the processed files, too. We'll use the processed list to
# determine which files are actually newly verified and need to be processed. If the
# reprocess flag is true, then we'll process all verified files.
if reprocess_files is not True:
processed_files = FileSync.get_file_list(input_dir, ext='.processed', recurse=True )
for processed_file in processed_files:
verified_files.remove( processed_file.replace('processed','verified') )
xlsx_workbook = None
excel_intf_ctrl = global_config.get('excel_sheets_intf', 'Disabled')
if excel_intf_ctrl == 'Enabled':
# read in the output file, which is expected to be an XLSX file
try:
xlsx_workbook = openpyxl.load_workbook(output_file)
except:
print 'Error Reading Spreadsheet %s For Input' % output_file
google_intf_ctrl = global_config.get('google_sheets_intf', 'Disabled')
'''
# took out for now until we have local dictionary storage
events = global_config.get('events')
if events is None:
events = {}
global_config['events'] = events
event_data = events.get( competition )
if event_data is None:
events[competition] = { 'ScoutingData': { 'TeamData': {} } }
event_data = events[competition]
event_scouting_data = event_data['ScoutingData']['TeamData']
'''
for verified_file in verified_files:
filename = verified_file.split('/')[-1]
# read the file into a dictionary
with open(input_dir+verified_file) as fd:
scouting_data = json.load(fd)
if filename.startswith('Match'):
team = scouting_data['Setup'].get('Team')
category = 'Match'
elif filename.startswith('Pit'):
team = scouting_data['Pit'].get('Team')
category = 'Pit'
else:
category = 'Unknown'
if team is not None and len(team) > 0:
# ######################################################### #
# store the scouting data to the local database
DataModel.addTeamToEvent(session, int(team), competition)
attr_definitions = AttributeDefinitions.AttrDefinitions(global_config)
for section_name, section_data in scouting_data.iteritems():
if isinstance(section_data,dict):
for attr_name, attr_value in section_data.iteritems():
# use the attribute definitions to control whether information gets
# stored to the database rather than the hard coded stuff here.
# also need to consider the section/category name as the attributes
# and definitions are processed
# don't store the team number in the database
if attr_name == 'Team':
continue
# augment the attribute name with the section name in order to make the attribute
# unique
attr_name = '%s:%s' % (section_name, attr_name)
attribute_def = {}
attribute_def['Name'] = attr_name
if attr_value.isdigit():
attribute_def['Type'] = 'Integer'
attribute_def['Weight'] = 1.0
else:
attribute_def['Type'] = 'String'
attribute_def['Weight'] = 0.0
attribute_def['Statistic_Type'] = 'Average'
attr_definitions.add_definition(attribute_def)
try:
DataModel.createOrUpdateAttribute(session, int(team), competition, category,
attr_name, attr_value, attribute_def)
except Exception, exception:
traceback.print_exc(file=sys.stdout)
#.........这里部分代码省略.........
示例3: run
# 需要导入模块: import FileSync [as 别名]
# 或者: from FileSync import get_file_list [as 别名]
def run(self):
server_sock=BluetoothSocket( RFCOMM )
server_sock.bind(("",PORT_ANY))
server_sock.listen(1)
port = server_sock.getsockname()[1]
uuid = "00001073-0000-1000-8000-00805F9B34F7"
advertise_service( server_sock, "TTTService",
service_id = uuid,
service_classes = [ uuid, SERIAL_PORT_CLASS ],
profiles = [ SERIAL_PORT_PROFILE ] )
while not self.shutdown:
print "Waiting for connection on RFCOMM channel %d" % port
client_sock, client_info = server_sock.accept()
print "Accepted connection from ", client_info
files_received = 0
try:
while True:
msg_header, msg_body, content_type = self.read_request( client_sock )
if len(msg_header) == 0:
break
print "Message Header: %s" % msg_header
print "Message Body Length: %d" % len(msg_body)
msg_header_lines = msg_header.splitlines()
request_type, request_path = msg_header_lines[0].split(' ',1)
print "Request Type: %s" % request_type
print "Request Path: %s" % request_path
if request_type == "PUT":
fullpath = './static/data/' + request_path
response_code = FileSync.put_file(fullpath, content_type, msg_body)
client_sock.send('HTTP/1.1 ' + response_code + '\r\n')
files_received += 1
elif request_type == "GET":
fullpath = './static/data/' + request_path
if os.path.isdir(fullpath):
file_list = FileSync.get_file_list(fullpath)
response_body = ''
for file_name in file_list:
response_body += file_name + '\n'
client_sock.send('HTTP/1.1 ' + '200 OK' + '\r\n')
client_sock.send('Content-Length: %d\r\n' % len(response_body))
client_sock.send('\r\n')
client_sock.send(response_body + '\r\n')
else:
response_body = FileSync.get_file(fullpath)
if response_body != '':
client_sock.send('HTTP/1.1 ' + '200 OK' + '\r\n')
client_sock.send('Content-Length: %d\r\n' % len(response_body))
client_sock.send('\r\n')
client_sock.send(response_body + '\r\n')
else:
client_sock.send('HTTP/1.1 ' + '404 Not Found' + '\r\n\r\n')
print "Request Complete\n"
except IOError:
pass
print "disconnected"
client_sock.close()
server_sock.close()
print "Bluetooth Sync Server Terminated"