def sync_directories(dir_list): check_dir(dir_list) dir1 = dir_list[0] dir2 = dir_list[1] list1 = sync.create_list_of_files(dir1) list2 = sync.create_list_of_files(dir2) print("sync...") new_file_list1 = [] for i in list1: found = False for j in list2: file1, key1 = i[:2] file2, key2 = j[:2] if key1 == key2: found = True synchro = sync.Sync(dir1 + file1, dir2 + file2) # Only syncs if files are not up-to-date if not synchro.up_to_date: synchro.sync_files() # Pops element of the second list if match was found to avoid unnecessary iterations list2.pop(list2.index(j)) continue # If no match was found for the element of the first list, that means that the file is new and needs to be # added to the second list, respectively second directory. This is done below. if not found: new_file_list1.append(i) list1 = new_file_list1 print(list1) print(list2) if list1: for i in list1: file, key = i[:2] synchro = sync.Sync(dir1 + file, dir2 + file) synchro.sync_files(True, key) if list2: for i in list2: file, key = i[:2] synchro = sync.Sync(dir1 + file, dir2 + file) synchro.sync_files(True, key)
def reverse_sync(argv): mp3_path = argv[0] book_path = argv[1] word = int(argv[2]) print("You run reverse-sync.") print("Path to mp3: " + mp3_path) print("Path to book: " + book_path) print("Run from word: " + str(word)) synchronizer = sync.Sync(PREPROCESSOR_PATH, mp3_path, book_path) synchronizer.sync_from_text(word, play=False)
def syncronize(argv): mp3_path = argv[0] book_path = argv[1] second = int(argv[2]) print("You run sync.") print("Path to mp3: " + mp3_path) print("Path to book: " + book_path) print("Run from sec: " + str(second)) synchronizer = sync.Sync(PREPROCESSOR_PATH, mp3_path, book_path) synchronizer.sync_from_audio(second, play=False)
def _on_sync_notes(self, widget = None, data = None): syncer = sync.Sync(self._db, self._window, 50504) syncer.connect("syncFinished", self._on_sync_finished) syncDialog = gtk.Dialog(_("Sync"), None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)) syncDialog.set_position(gtk.WIN_POS_CENTER) syncDialog.vbox.pack_start(syncer, True, True, 0) syncDialog.set_size_request(500, 350) syncDialog.vbox.show_all() syncDialog.run() syncDialog.hide()
def getLatest(self): # print "DEBUG:", fpath latest = sync.Sync().getLatest(self.fpath) oM = re.match(self.__facts__["CH_FILE_RE"], latest.basename()) if oM: dM = oM.groupdict() version = int(dM["version"]) if version != self.__version__: return Char(self.__name__, version, latest) else: self.__fpath__ = latest return self
def SYNC(m, r): try: os.mkdir("../final") except: pass # The directory where you save the final results res_dir = "../final" # The ratio of top models you want to fetch for both rankings ratio = 0.5 print "********************" print "Synchronizing..." # Create an instance of the 'Sync' class syn = sync.Sync(m, r, res_dir, ratio) syn.run() print "Synchronizing complete!" return syn
from telegram.ext import Updater, MessageHandler, CommandHandler, Filters import logging import json import common from datetime import datetime import sync import os.path logging.basicConfig(filename = os.path.join(common.root_path, 'log'), format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO) req = telegram.utils.request.Request(proxy_url= common.proxy) bot = telegram.Bot(common.token, request= req) #bot = telegram.Bot(common.token) sync_file = sync.Sync() #BOT = telegram.Bot(common.TOKEN) #log = logging.Logger(__name__) def command_process(bot, update): #print(type(update)) text = update.message.text logging.info(text) if text.startswith('/help') or text.startswith('/start'): bot.send_message(chat_id=update.message.chat_id, text= common.command_str) elif text.startswith('/weather'): bot.send_message(chat_id=update.message.chat_id, text= common.get_weather()) elif text.startswith('/gif'): url = common.get_random_gif()
return v # beancount settings bean_path = _must_get("BEAN_PATH") """The path to your beancount folder.""" bean_main_file = _must_get("BEAN_MAIN_FILE") """The name of the main beancount file expressed as relative path to `bean_path``.""" bean_currency = _must_get("BEAN_CURRENCY") """The currency string used for your accounts, e.g. EUR or USD.""" # telegram settings telegram_api_token = _must_get("TELEGRAM_API_TOKEN") """Telegram API token for your bot.""" # Logging information db_dir = os.environ.get("DB_DIR") or "/var/lib/beanbot" """The directory in which persistent data will be stored.""" verbose = os.environ.get("LOG_VERBOSE") in ["True", "true", "1"] """Indicates whether verbose logging is activated.""" log_lvl = logging.DEBUG if verbose else logging.INFO """Current log level used in all loggers.""" # Synchronation settings synchronizer = sync.Sync(bean_path) if os.environ.get("SYNC_METHOD") == "dav": # DAV settings dpath = _must_get("DAV_PATH") droot = _must_get("DAV_ROOT") duser = _must_get("DAV_USER") dpass = _must_get("DAV_PASS") dhost = _must_get("DAV_HOST") synchronizer = sync.DavSync(bean_path, dpath, droot, duser, dpass, dhost)
logmsg("mappings: %s" % (mappings)) if mappings: ctx = { # We don't have any process id while debugging Cisco ASA # so we hardcode it "pid": 200, # There is no mapping returned by "info proc mappings" # so we hardcode it # (gdb) info proc mappings # Can't determine the current process's PID: you must name one. "mappings": mappings } sync = rs.Sync(HOST, PORT, ctx=ctx) ##### end of Cisco ASA specific rs.Syncoff(sync) rs.Syncmodauto(sync) rs.Idblist(sync) rs.Idbn(sync) rs.Cmt(sync) rs.Rcmt(sync) rs.Fcmt(sync) rs.Bc(sync) rs.Translate(sync) rs.Cmd(sync) rs.Rln(sync) rs.Bbt(sync) rs.Bx(sync)
if (con.recieve().decode("utf8") == 1): print("Wrong password. Please change it in the config.ini file.") con.close() exit() if (not (isInConfig(configFile, 'syncdata'))): getSyncData(con) clientid = getProperty(configFile, 'syncdata', 'clientid') con.send(bytes("3 " + clientid, "utf8")) import sync import time syncdir = getProperty(configFile, 'config', 'syncpath') sy = sync.Sync(syncdir, con) i = 0 while True: if (i == 11): # Force checking if there is something to sync every minute. Sometimes the check for the time is not enough. i = 0 sy.sync(True) else: sy.sync() time.sleep(5) # Wait 5 seconds until the next try of syncing i += 1 # Send exit code con.send(bytes("16", "utf8"))
optNames = configParser.options('peer-config') peerAddrPortPairs = [] for optName in optNames: addrPort = configParser.get('peer-config', optName) ipaddr, port = addrPort.strip().rsplit(':', maxsplit=1) port = int(port) peerAddrPortPairs.append((ipaddr, port)) file = open(contentFilePath, 'r', encoding='utf-8') words = file.readline().split(' ') effectiveData = GetEffectiveData(words) file.close() localAddrPort = (localAddr, localPort) syncer = sync.Sync(BC, localAddrPort, peerAddrPortPairs, RTO) while BC.height < len(effectiveData): # work out the component in the block we are going to dig in this round height = bytes(str(BC.height), 'utf-8').ljust(8, b' ') content = effectiveData[BC.height] parentHash = GetMd5AsHex(BC.GetTop()) timestamp = bytes(time.asctime()[4:24], 'utf-8') Node = GetValidNode(content, height, localId, timestamp, parentHash, difficulty) if Node is not None: BC.Update(Node, False) syncer.DoSync()
if __name__ == '__main__': args = parse_args() metadata = retrieve_spotify_metadata() artist = metadata['xesam:artist'][0] title = metadata['xesam:title'].split(" (feat.", 1)[0] title = title.split(' (with', 1)[0] print('{0} - {1}'.format(artist, title)) az = Azlyrics(artist, title) lyrics = az.get_lyrics() formatted_lyrics = az.format_lyrics(lyrics) sync = sync.Sync(artist, title) if args.sync: synced_lyrics = '' restart_song() for phrase in formatted_lyrics.splitlines(): start_time = time.time() input() print(phrase) synced_lyrics += '{}\t{}\n'.format(str(time.time() - start_time), phrase) sync.save_synced_lyrics(synced_lyrics) else: if not sync.is_synced(): print(formatted_lyrics)
class MainScreen(Screen): # mp3 = AudioSegment.from_mp3("res/harry.mp3") mp3 = AudioSegment.from_mp3("res/harry/harry-big.mp3") audio_length = int(len(mp3) / 1000) mp3.export("res/harry/harry-big.wav", format="wav") audio = SoundLoader.load('res/harry/harry-big.wav') synchronizer = sync.Sync(PATH + "../res/sync_db-big.txt", PATH + "../res/harry.mp3", PATH + "../res/harry.fb2") current_second = 0 current_page = 1 current_selected_word = -1 book_worker = book.BookWorker(PATH + "../res/harry.fb2") book_text = book_worker.get_book_text_from_tree() spliced_book = book_text.split() pages = int(len(book_text) / PAGE_LENGTH) + 1 seek_size = 30 def __init__(self, **kw): super().__init__(**kw) self.lbl_pages.text = str(self.current_page) + "/" + str(self.pages) self.txt_input.text = self.book_text[ (self.current_page - 1) * PAGE_LENGTH:(self.current_page - 1) * PAGE_LENGTH + PAGE_LENGTH] Clock.schedule_interval(self.timer, 1) def update_page(self): self.txt_input.text = self.book_text[(self.current_page - 1) * PAGE_LENGTH:self.current_page * PAGE_LENGTH] self.lbl_pages.text = str(self.current_page) + "/" + str(self.pages) def play_audio(self): if self.audio.state != "play": self.btn_play.source = "pause.png" self.audio.play() self.audio.seek(self.current_second) def stop_audio(self): if self.audio.state == "play": self.btn_play.source = "play.png" self.current_second = self.audio.get_pos() self.audio.stop() def play_click(self, instance): if self.audio.state == "play": self.stop_audio() else: self.play_audio() def timer(self, dt): if self.audio.state == "play": self.current_second += 1 self.update_time() self.time_slider.value = int(self.current_second * 100 / self.audio_length) sync_word = self.synchronizer.sync_from_audio( self.current_second, False) if sync_word != self.current_selected_word: self.current_selected_word = sync_word count_words = sync_word count_symbols = 0 while count_words != 0: count_symbols += len(self.spliced_book[count_words - 1]) count_symbols += 1 # space between words count_words -= 1 pages = math.ceil(count_symbols / PAGE_LENGTH) self.current_page = pages self.update_page() while count_symbols > PAGE_LENGTH: count_symbols -= PAGE_LENGTH self.txt_input.select_text(count_symbols, count_symbols + 100) def audio_seek(self, direction): if self.audio.state == "play": if direction == "Back": if self.current_second - self.seek_size > 0: self.current_second -= self.seek_size else: self.current_second = 0 elif direction == "Forward": if self.current_second + self.seek_size > self.audio_length: self.current_second = self.audio_length - 10 else: self.current_second += self.seek_size self.audio.seek(self.current_second) def time_slider_touch_up(self, touch): touch_x = touch.pos[0] touch_y = touch.pos[1] if 320 < touch_x < 570 and 18 < touch_y < 53: self.play_audio() # if self.audio.state == "play": # self.audio.seek(self.current_second) def time_slider_moved(self, touch): touch_x, touch_y = touch.pos[0], touch.pos[1] if 320 < touch_x < 570 and 18 < touch_y < 53: self.stop_audio() self.current_second = int(self.audio_length * self.time_slider.value / 100) self.update_time() # self.play_audio_from_current_sec() def play_audio_from_current_sec(self): if self.audio.state == "play": self.audio.stop() self.audio.play() self.audio.seek(self.current_second) def update_time(self): hours = 0 minutes = 0 seconds = int(self.current_second) while seconds > 59: minutes += 1 seconds -= 59 while minutes > 59: hours += 1 minutes -= 59 if hours < 10: hours = "0" + str(hours) if minutes < 10: minutes = "0" + str(minutes) if seconds < 10: seconds = "0" + str(seconds) self.lbl_time.text = "{}:{}:{}".format(hours, minutes, seconds) self.time_slider.value = int(self.current_second * 100 / self.audio_length) def text_input_touched(self, touch): touch_position = touch.pos touch_x = touch_position[0] touch_y = touch_position[1] if 550 >= touch_y >= 65: if touch_x < 300: if self.current_page > 1: self.current_page -= 1 self.update_page() else: if self.current_page <= self.pages: self.current_page += 1 self.update_page() count_symbols = PAGE_LENGTH * self.current_page count_words = 0 audio_played = self.audio.state == "play" if audio_played: self.stop_audio() while count_symbols > 0: count_symbols -= len(self.spliced_book[count_words]) count_symbols -= 1 count_words += 1 if self.current_page == 1: self.current_second = 0 else: self.current_second = self.synchronizer.sync_from_text( count_words, False) self.update_page() self.update_time() if audio_played: self.play_audio()