Committer:
borlanic
Date:
Fri Mar 30 14:07:05 2018 +0000
Revision:
4:75df35ef4fb6
Parent:
0:380207fcb5c1
commentar

Who changed what in which revision?

UserRevisionLine numberNew contents of line
borlanic 0:380207fcb5c1 1 """
borlanic 0:380207fcb5c1 2 mbed SDK
borlanic 0:380207fcb5c1 3 Copyright (c) 2011-2013 ARM Limited
borlanic 0:380207fcb5c1 4
borlanic 0:380207fcb5c1 5 Licensed under the Apache License, Version 2.0 (the "License");
borlanic 0:380207fcb5c1 6 you may not use this file except in compliance with the License.
borlanic 0:380207fcb5c1 7 You may obtain a copy of the License at
borlanic 0:380207fcb5c1 8
borlanic 0:380207fcb5c1 9 http://www.apache.org/licenses/LICENSE-2.0
borlanic 0:380207fcb5c1 10
borlanic 0:380207fcb5c1 11 Unless required by applicable law or agreed to in writing, software
borlanic 0:380207fcb5c1 12 distributed under the License is distributed on an "AS IS" BASIS,
borlanic 0:380207fcb5c1 13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
borlanic 0:380207fcb5c1 14 See the License for the specific language governing permissions and
borlanic 0:380207fcb5c1 15 limitations under the License.
borlanic 0:380207fcb5c1 16
borlanic 0:380207fcb5c1 17
borlanic 0:380207fcb5c1 18 One repository to update them all
borlanic 0:380207fcb5c1 19 On mbed.org the mbed SDK is split up in multiple repositories, this script takes
borlanic 0:380207fcb5c1 20 care of updating them all.
borlanic 0:380207fcb5c1 21 """
borlanic 0:380207fcb5c1 22 import sys
borlanic 0:380207fcb5c1 23 from copy import copy
borlanic 0:380207fcb5c1 24 from os import walk, remove, makedirs, getcwd, rmdir, listdir
borlanic 0:380207fcb5c1 25 from os.path import join, abspath, dirname, relpath, exists, isfile, normpath, isdir
borlanic 0:380207fcb5c1 26 from shutil import copyfile
borlanic 0:380207fcb5c1 27 from optparse import OptionParser
borlanic 0:380207fcb5c1 28 import re
borlanic 0:380207fcb5c1 29 import string
borlanic 0:380207fcb5c1 30
borlanic 0:380207fcb5c1 31 ROOT = abspath(join(dirname(__file__), ".."))
borlanic 0:380207fcb5c1 32 sys.path.insert(0, ROOT)
borlanic 0:380207fcb5c1 33
borlanic 0:380207fcb5c1 34 from tools.settings import MBED_ORG_PATH, MBED_ORG_USER, BUILD_DIR
borlanic 0:380207fcb5c1 35 from tools.paths import *
borlanic 0:380207fcb5c1 36 from tools.utils import run_cmd
borlanic 0:380207fcb5c1 37
borlanic 0:380207fcb5c1 38 MBED_URL = "mbed.org"
borlanic 0:380207fcb5c1 39 MBED_USER = "mbed_official"
borlanic 0:380207fcb5c1 40
borlanic 0:380207fcb5c1 41 changed = []
borlanic 0:380207fcb5c1 42 push_remote = True
borlanic 0:380207fcb5c1 43 quiet = False
borlanic 0:380207fcb5c1 44 commit_msg = ''
borlanic 0:380207fcb5c1 45
borlanic 0:380207fcb5c1 46 # Code that does have a mirror in the mbed SDK
borlanic 0:380207fcb5c1 47 # Tuple data: (repo_name, list_of_code_dirs, [team])
borlanic 0:380207fcb5c1 48 # team is optional - if not specified, the code is published under mbed_official
borlanic 0:380207fcb5c1 49 OFFICIAL_CODE = {"mbed-dev" : ["cmsis", "drivers", "hal", "platform", "targets", "mbed.h"]}
borlanic 0:380207fcb5c1 50
borlanic 0:380207fcb5c1 51
borlanic 0:380207fcb5c1 52 # A list of regular expressions that will be checked against each directory
borlanic 0:380207fcb5c1 53 # name and skipped if they match.
borlanic 0:380207fcb5c1 54 IGNORE_DIRS = (
borlanic 0:380207fcb5c1 55 )
borlanic 0:380207fcb5c1 56
borlanic 0:380207fcb5c1 57 IGNORE_FILES = (
borlanic 0:380207fcb5c1 58 'COPYING',
borlanic 0:380207fcb5c1 59 '\.md',
borlanic 0:380207fcb5c1 60 "\.lib",
borlanic 0:380207fcb5c1 61 "\.bld"
borlanic 0:380207fcb5c1 62 )
borlanic 0:380207fcb5c1 63
borlanic 0:380207fcb5c1 64 def ignore_path(name, reg_exps):
borlanic 0:380207fcb5c1 65 for r in reg_exps:
borlanic 0:380207fcb5c1 66 if re.search(r, name):
borlanic 0:380207fcb5c1 67 return True
borlanic 0:380207fcb5c1 68 return False
borlanic 0:380207fcb5c1 69
borlanic 0:380207fcb5c1 70 class MbedRepository:
borlanic 0:380207fcb5c1 71 @staticmethod
borlanic 0:380207fcb5c1 72 def run_and_print(command, cwd):
borlanic 0:380207fcb5c1 73 stdout, _, _ = run_cmd(command, work_dir=cwd, redirect=True)
borlanic 0:380207fcb5c1 74 print(stdout)
borlanic 0:380207fcb5c1 75
borlanic 0:380207fcb5c1 76 def __init__(self, name):
borlanic 0:380207fcb5c1 77 self.name = name
borlanic 0:380207fcb5c1 78 self.path = join(MBED_ORG_PATH, name)
borlanic 0:380207fcb5c1 79 self.url = "http://" + MBED_URL + "/users/" + MBED_ORG_USER + "/code/%s/"
borlanic 0:380207fcb5c1 80
borlanic 0:380207fcb5c1 81 if not exists(self.path):
borlanic 0:380207fcb5c1 82 # Checkout code
borlanic 0:380207fcb5c1 83 if not exists(MBED_ORG_PATH):
borlanic 0:380207fcb5c1 84 makedirs(MBED_ORG_PATH)
borlanic 0:380207fcb5c1 85
borlanic 0:380207fcb5c1 86 self.run_and_print(['hg', 'clone', self.url % name], cwd=MBED_ORG_PATH)
borlanic 0:380207fcb5c1 87
borlanic 0:380207fcb5c1 88 else:
borlanic 0:380207fcb5c1 89 # Update
borlanic 0:380207fcb5c1 90 self.run_and_print(['hg', 'pull'], cwd=self.path)
borlanic 0:380207fcb5c1 91 self.run_and_print(['hg', 'update'], cwd=self.path)
borlanic 0:380207fcb5c1 92
borlanic 0:380207fcb5c1 93 def publish(self):
borlanic 0:380207fcb5c1 94 # The maintainer has to evaluate the changes first and explicitly accept them
borlanic 0:380207fcb5c1 95 self.run_and_print(['hg', 'addremove'], cwd=self.path)
borlanic 0:380207fcb5c1 96 stdout, _, _ = run_cmd(['hg', 'status'], work_dir=self.path)
borlanic 0:380207fcb5c1 97 if stdout == '':
borlanic 0:380207fcb5c1 98 print "No changes"
borlanic 0:380207fcb5c1 99 return False
borlanic 0:380207fcb5c1 100 print stdout
borlanic 0:380207fcb5c1 101 if quiet:
borlanic 0:380207fcb5c1 102 commit = 'Y'
borlanic 0:380207fcb5c1 103 else:
borlanic 0:380207fcb5c1 104 commit = raw_input(push_remote and "Do you want to commit and push? Y/N: " or "Do you want to commit? Y/N: ")
borlanic 0:380207fcb5c1 105 if commit == 'Y':
borlanic 0:380207fcb5c1 106 args = ['hg', 'commit', '-u', MBED_ORG_USER]
borlanic 0:380207fcb5c1 107
borlanic 0:380207fcb5c1 108
borlanic 0:380207fcb5c1 109 # NOTE commit_msg should always come from the relevant mbed 2 release text
borlanic 0:380207fcb5c1 110 if commit_msg:
borlanic 0:380207fcb5c1 111 args = args + ['-m', commit_msg]
borlanic 0:380207fcb5c1 112 self.run_and_print(args, cwd=self.path)
borlanic 0:380207fcb5c1 113 if push_remote:
borlanic 0:380207fcb5c1 114 self.run_and_print(['hg', 'push'], cwd=self.path)
borlanic 0:380207fcb5c1 115 return True
borlanic 0:380207fcb5c1 116
borlanic 0:380207fcb5c1 117 # Check if a file is a text file or a binary file
borlanic 0:380207fcb5c1 118 # Taken from http://code.activestate.com/recipes/173220/
borlanic 0:380207fcb5c1 119 text_characters = "".join(map(chr, range(32, 127)) + list("\n\r\t\b"))
borlanic 0:380207fcb5c1 120 _null_trans = string.maketrans("", "")
borlanic 0:380207fcb5c1 121 def is_text_file(filename):
borlanic 0:380207fcb5c1 122 block_size = 1024
borlanic 0:380207fcb5c1 123 def istext(s):
borlanic 0:380207fcb5c1 124 if "\0" in s:
borlanic 0:380207fcb5c1 125 return 0
borlanic 0:380207fcb5c1 126
borlanic 0:380207fcb5c1 127 if not s: # Empty files are considered text
borlanic 0:380207fcb5c1 128 return 1
borlanic 0:380207fcb5c1 129
borlanic 0:380207fcb5c1 130 # Get the non-text characters (maps a character to itself then
borlanic 0:380207fcb5c1 131 # use the 'remove' option to get rid of the text characters.)
borlanic 0:380207fcb5c1 132 t = s.translate(_null_trans, text_characters)
borlanic 0:380207fcb5c1 133
borlanic 0:380207fcb5c1 134 # If more than 30% non-text characters, then
borlanic 0:380207fcb5c1 135 # this is considered a binary file
borlanic 0:380207fcb5c1 136 if float(len(t))/len(s) > 0.30:
borlanic 0:380207fcb5c1 137 return 0
borlanic 0:380207fcb5c1 138 return 1
borlanic 0:380207fcb5c1 139 with open(filename) as f:
borlanic 0:380207fcb5c1 140 res = istext(f.read(block_size))
borlanic 0:380207fcb5c1 141 return res
borlanic 0:380207fcb5c1 142
borlanic 0:380207fcb5c1 143 # Return the line ending type for the given file ('cr' or 'crlf')
borlanic 0:380207fcb5c1 144 def get_line_endings(f):
borlanic 0:380207fcb5c1 145 examine_size = 1024
borlanic 0:380207fcb5c1 146 try:
borlanic 0:380207fcb5c1 147 tf = open(f, "rb")
borlanic 0:380207fcb5c1 148 lines, ncrlf = tf.readlines(examine_size), 0
borlanic 0:380207fcb5c1 149 tf.close()
borlanic 0:380207fcb5c1 150 for l in lines:
borlanic 0:380207fcb5c1 151 if l.endswith("\r\n"):
borlanic 0:380207fcb5c1 152 ncrlf = ncrlf + 1
borlanic 0:380207fcb5c1 153 return 'crlf' if ncrlf > len(lines) >> 1 else 'cr'
borlanic 0:380207fcb5c1 154 except:
borlanic 0:380207fcb5c1 155 return 'cr'
borlanic 0:380207fcb5c1 156
borlanic 0:380207fcb5c1 157 # Copy file to destination, but preserve destination line endings if possible
borlanic 0:380207fcb5c1 158 # This prevents very annoying issues with huge diffs that appear because of
borlanic 0:380207fcb5c1 159 # differences in line endings
borlanic 0:380207fcb5c1 160 def copy_with_line_endings(sdk_file, repo_file):
borlanic 0:380207fcb5c1 161 if not isfile(repo_file):
borlanic 0:380207fcb5c1 162 copyfile(sdk_file, repo_file)
borlanic 0:380207fcb5c1 163 return
borlanic 0:380207fcb5c1 164 is_text = is_text_file(repo_file)
borlanic 0:380207fcb5c1 165 if is_text:
borlanic 0:380207fcb5c1 166 sdk_le = get_line_endings(sdk_file)
borlanic 0:380207fcb5c1 167 repo_le = get_line_endings(repo_file)
borlanic 0:380207fcb5c1 168 if not is_text or sdk_le == repo_le:
borlanic 0:380207fcb5c1 169 copyfile(sdk_file, repo_file)
borlanic 0:380207fcb5c1 170 else:
borlanic 0:380207fcb5c1 171 print "Converting line endings in '%s' to '%s'" % (abspath(repo_file), repo_le)
borlanic 0:380207fcb5c1 172 f = open(sdk_file, "rb")
borlanic 0:380207fcb5c1 173 data = f.read()
borlanic 0:380207fcb5c1 174 f.close()
borlanic 0:380207fcb5c1 175 f = open(repo_file, "wb")
borlanic 0:380207fcb5c1 176 data = data.replace("\r\n", "\n") if repo_le == 'cr' else data.replace('\n','\r\n')
borlanic 0:380207fcb5c1 177 f.write(data)
borlanic 0:380207fcb5c1 178 f.close()
borlanic 0:380207fcb5c1 179
borlanic 0:380207fcb5c1 180 def visit_files(path, visit):
borlanic 0:380207fcb5c1 181 for root, dirs, files in walk(path):
borlanic 0:380207fcb5c1 182 # Ignore hidden directories
borlanic 0:380207fcb5c1 183 for d in copy(dirs):
borlanic 0:380207fcb5c1 184 full = join(root, d)
borlanic 0:380207fcb5c1 185 if d.startswith('.'):
borlanic 0:380207fcb5c1 186 dirs.remove(d)
borlanic 0:380207fcb5c1 187 if ignore_path(full, IGNORE_DIRS):
borlanic 0:380207fcb5c1 188 print "Skipping '%s'" % full
borlanic 0:380207fcb5c1 189 dirs.remove(d)
borlanic 0:380207fcb5c1 190
borlanic 0:380207fcb5c1 191 for file in files:
borlanic 0:380207fcb5c1 192 if ignore_path(file, IGNORE_FILES):
borlanic 0:380207fcb5c1 193 continue
borlanic 0:380207fcb5c1 194
borlanic 0:380207fcb5c1 195 visit(join(root, file))
borlanic 0:380207fcb5c1 196
borlanic 0:380207fcb5c1 197 def visit_dirs(path, visit):
borlanic 0:380207fcb5c1 198
borlanic 0:380207fcb5c1 199 for root, dirs, files in walk(path, topdown=False):
borlanic 0:380207fcb5c1 200 for d in dirs:
borlanic 0:380207fcb5c1 201 full = join(root, d)
borlanic 0:380207fcb5c1 202
borlanic 0:380207fcb5c1 203 # We don't want to remove the .hg directory
borlanic 0:380207fcb5c1 204 if not '.hg' in full:
borlanic 0:380207fcb5c1 205 visit(full)
borlanic 0:380207fcb5c1 206
borlanic 0:380207fcb5c1 207
borlanic 0:380207fcb5c1 208 def update_repo(repo_name, sdk_paths, lib=False):
borlanic 0:380207fcb5c1 209 repo = MbedRepository(repo_name)
borlanic 0:380207fcb5c1 210
borlanic 0:380207fcb5c1 211 # copy files from mbed SDK to mbed_official repository
borlanic 0:380207fcb5c1 212 def visit_mbed_sdk(sdk_file):
borlanic 0:380207fcb5c1 213
borlanic 0:380207fcb5c1 214 # Source files structure is different for the compiled binary lib
borlanic 0:380207fcb5c1 215 # compared to the mbed-dev sources
borlanic 0:380207fcb5c1 216 if lib:
borlanic 0:380207fcb5c1 217 repo_file = join(repo.path, relpath(sdk_file, sdk_path))
borlanic 0:380207fcb5c1 218 else:
borlanic 0:380207fcb5c1 219 repo_file = join(repo.path, sdk_file)
borlanic 0:380207fcb5c1 220 repo_dir = dirname(repo_file)
borlanic 0:380207fcb5c1 221 if not exists(repo_dir):
borlanic 0:380207fcb5c1 222 print("CREATING: %s" % repo_dir)
borlanic 0:380207fcb5c1 223 makedirs(repo_dir)
borlanic 0:380207fcb5c1 224
borlanic 0:380207fcb5c1 225 copy_with_line_endings(sdk_file, repo_file)
borlanic 0:380207fcb5c1 226
borlanic 0:380207fcb5c1 227 # Go through each path specified in the mbed structure
borlanic 0:380207fcb5c1 228 for sdk_path in sdk_paths:
borlanic 0:380207fcb5c1 229
borlanic 0:380207fcb5c1 230 if isfile(sdk_path):
borlanic 0:380207fcb5c1 231 # Single file so just copy directly across
borlanic 0:380207fcb5c1 232 visit_mbed_sdk(sdk_path)
borlanic 0:380207fcb5c1 233 else:
borlanic 0:380207fcb5c1 234 visit_files(sdk_path, visit_mbed_sdk)
borlanic 0:380207fcb5c1 235
borlanic 0:380207fcb5c1 236 def sdk_remove(repo_path):
borlanic 0:380207fcb5c1 237
borlanic 0:380207fcb5c1 238 print("REMOVING: %s" % repo_path)
borlanic 0:380207fcb5c1 239
borlanic 0:380207fcb5c1 240 # Check if this is an empty directory or a file before determining how to
borlanic 0:380207fcb5c1 241 # delete it. As this function should only be called with a directory list
borlanic 0:380207fcb5c1 242 # after being called with a file list, the directory should automatically
borlanic 0:380207fcb5c1 243 # be either valid or empty .
borlanic 0:380207fcb5c1 244 if isfile(repo_path):
borlanic 0:380207fcb5c1 245 remove(repo_path)
borlanic 0:380207fcb5c1 246 elif isdir(repo_path) and not listdir(repo_path):
borlanic 0:380207fcb5c1 247 rmdir(repo_path)
borlanic 0:380207fcb5c1 248 else:
borlanic 0:380207fcb5c1 249 print("ERROR: %s is not empty, please remove manually." % repo_path)
borlanic 0:380207fcb5c1 250 print listdir(repo_path)
borlanic 0:380207fcb5c1 251 exit(1)
borlanic 0:380207fcb5c1 252
borlanic 0:380207fcb5c1 253 # remove repository files that do not exist in the mbed SDK
borlanic 0:380207fcb5c1 254 def visit_lib_repo(repo_path):
borlanic 0:380207fcb5c1 255 for sdk_path in sdk_paths:
borlanic 0:380207fcb5c1 256 sdk_file = join(sdk_path, relpath(repo_path, repo.path))
borlanic 0:380207fcb5c1 257 if not exists(sdk_file):
borlanic 0:380207fcb5c1 258 sdk_remove(repo_path)
borlanic 0:380207fcb5c1 259
borlanic 0:380207fcb5c1 260 # remove repository files that do not exist in the mbed SDK source
borlanic 0:380207fcb5c1 261 def visit_repo(repo_path):
borlanic 0:380207fcb5c1 262
borlanic 0:380207fcb5c1 263 # work out equivalent sdk path from repo file
borlanic 0:380207fcb5c1 264 sdk_path = join(getcwd(), relpath(repo_path, repo.path))
borlanic 0:380207fcb5c1 265
borlanic 0:380207fcb5c1 266 if not exists(sdk_path):
borlanic 0:380207fcb5c1 267 sdk_remove(repo_path)
borlanic 0:380207fcb5c1 268
borlanic 0:380207fcb5c1 269 # Go through each path specified in the mbed structure
borlanic 0:380207fcb5c1 270 # Check if there are any files in any of those paths that are no longer part of the SDK
borlanic 0:380207fcb5c1 271
borlanic 0:380207fcb5c1 272 if lib:
borlanic 0:380207fcb5c1 273 visit_files(repo.path, visit_lib_repo)
borlanic 0:380207fcb5c1 274 # Now do the same for directories that may need to be removed. This needs to be done
borlanic 0:380207fcb5c1 275 # bottom up to ensure any lower nested directories can be deleted first
borlanic 0:380207fcb5c1 276 visit_dirs(repo.path, visit_lib_repo)
borlanic 0:380207fcb5c1 277
borlanic 0:380207fcb5c1 278 else:
borlanic 0:380207fcb5c1 279 visit_files(repo.path, visit_repo)
borlanic 0:380207fcb5c1 280
borlanic 0:380207fcb5c1 281 # Now do the same for directories that may need to be removed. This needs to be done
borlanic 0:380207fcb5c1 282 # bottom up to ensure any lower nested directories can be deleted first
borlanic 0:380207fcb5c1 283 visit_dirs(repo.path, visit_repo)
borlanic 0:380207fcb5c1 284
borlanic 0:380207fcb5c1 285 if repo.publish():
borlanic 0:380207fcb5c1 286 changed.append(repo_name)
borlanic 0:380207fcb5c1 287
borlanic 0:380207fcb5c1 288
borlanic 0:380207fcb5c1 289 def update_code(repositories):
borlanic 0:380207fcb5c1 290 for repo_name in repositories.keys():
borlanic 0:380207fcb5c1 291 sdk_dirs = repositories[repo_name]
borlanic 0:380207fcb5c1 292 print '\n=== Updating "%s" ===' % repo_name
borlanic 0:380207fcb5c1 293 update_repo(repo_name, sdk_dirs)
borlanic 0:380207fcb5c1 294
borlanic 0:380207fcb5c1 295
borlanic 0:380207fcb5c1 296 def update_mbed():
borlanic 0:380207fcb5c1 297 update_repo("mbed", [join(BUILD_DIR, "mbed")], lib=True)
borlanic 0:380207fcb5c1 298
borlanic 0:380207fcb5c1 299 def do_sync(options):
borlanic 0:380207fcb5c1 300 global push_remote, quiet, commit_msg, changed
borlanic 0:380207fcb5c1 301
borlanic 0:380207fcb5c1 302 push_remote = not options.nopush
borlanic 0:380207fcb5c1 303 quiet = options.quiet
borlanic 0:380207fcb5c1 304 commit_msg = options.msg
borlanic 0:380207fcb5c1 305 changed = []
borlanic 0:380207fcb5c1 306
borlanic 0:380207fcb5c1 307 if options.code:
borlanic 0:380207fcb5c1 308 update_code(OFFICIAL_CODE)
borlanic 0:380207fcb5c1 309
borlanic 0:380207fcb5c1 310 if options.mbed:
borlanic 0:380207fcb5c1 311 update_mbed()
borlanic 0:380207fcb5c1 312
borlanic 0:380207fcb5c1 313 if changed:
borlanic 0:380207fcb5c1 314 print "Repositories with changes:", changed
borlanic 0:380207fcb5c1 315
borlanic 0:380207fcb5c1 316 return changed
borlanic 0:380207fcb5c1 317
borlanic 0:380207fcb5c1 318 if __name__ == '__main__':
borlanic 0:380207fcb5c1 319 parser = OptionParser()
borlanic 0:380207fcb5c1 320
borlanic 0:380207fcb5c1 321 parser.add_option("-c", "--code",
borlanic 0:380207fcb5c1 322 action="store_true", default=False,
borlanic 0:380207fcb5c1 323 help="Update the mbed_official code")
borlanic 0:380207fcb5c1 324
borlanic 0:380207fcb5c1 325 parser.add_option("-m", "--mbed",
borlanic 0:380207fcb5c1 326 action="store_true", default=False,
borlanic 0:380207fcb5c1 327 help="Release a build of the mbed library")
borlanic 0:380207fcb5c1 328
borlanic 0:380207fcb5c1 329 parser.add_option("-n", "--nopush",
borlanic 0:380207fcb5c1 330 action="store_true", default=False,
borlanic 0:380207fcb5c1 331 help="Commit the changes locally only, don't push them")
borlanic 0:380207fcb5c1 332
borlanic 0:380207fcb5c1 333 parser.add_option("", "--commit_message",
borlanic 0:380207fcb5c1 334 action="store", type="string", default='', dest='msg',
borlanic 0:380207fcb5c1 335 help="Commit message to use for all the commits")
borlanic 0:380207fcb5c1 336
borlanic 0:380207fcb5c1 337 parser.add_option("-q", "--quiet",
borlanic 0:380207fcb5c1 338 action="store_true", default=False,
borlanic 0:380207fcb5c1 339 help="Don't ask for confirmation before commiting or pushing")
borlanic 0:380207fcb5c1 340
borlanic 0:380207fcb5c1 341 (options, args) = parser.parse_args()
borlanic 0:380207fcb5c1 342
borlanic 0:380207fcb5c1 343 do_sync(options)
borlanic 0:380207fcb5c1 344